import java.util.*;
import java.util.Stack;

public class Solution {
    private Stack<Integer> stack = new Stack<>();

    public void push(int node) {
        stack.push(node);
    }

    public void pop() {
        stack.pop();
    }

    public int top() {
        return stack.peek();
    }

    public int min() {
        Stack<Integer> tmp = new Stack<>();
        Integer pop = null;
        while(!stack.isEmpty()) {
            Integer cu = stack.pop();
            if(pop == null) {
                pop = cu;
            }
            if(pop > cu) {
                pop = cu;
            }
            tmp.push(cu);
        }
        while(!tmp.isEmpty()) {
            stack.push(tmp.pop());
        }
        return pop;
    }
}