import java.util.Stack;
import java.util.PriorityQueue;

public class Solution {


    PriorityQueue<Integer> priorityQueue = new PriorityQueue<Integer>();
    Stack<Integer> stack = new Stack<Integer>();

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

    public void pop() {
        priorityQueue.remove(stack.peek());
        stack.pop();
    }

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

    public int min() {
        return priorityQueue.peek();
    }
}