public class Solution {
    Stack<Integer> minStack=new Stack<>();
    int min=Integer.MAX_VALUE;
    
    public void push(int node) {
        if(node<min) min=node;
        minStack.push(node);
    }
    
    public void pop() {
        minStack.pop();
        min=Integer.MAX_VALUE;
        for(int i=0;i<minStack.size();i++){
            if(minStack.get(i)<min) min=minStack.get(i);
        }
    }
    
    public int top() {
        return minStack.peek();
    }
    
    public int min() {
        return min;
    }
}