import java.util.*;

public class Solution {
    Deque<Integer> stack = new LinkedList<>();
    Deque<Integer> min = new LinkedList<>();
    public void push(int node) {
        if(min.isEmpty()) min.push(node);
        else if(min.peek() < node){
            min.push(min.peek());
        }else {
            min.push(node);
        }
        stack.push(node);
    }
    
    public void pop() {
        stack.pop();
        min.pop();
    }
    
    public int top() {
        return stack.peek();
    }
    
    public int min() {
        return min.peek();
    }
}