class Solution {
public:
    stack<int> s;
    stack<int> t;
    void push(int value) {
        s.push(value);
        if(t.empty() || t.top()>value)
        t.push(value);
        else
        {
            int tem = t.top();
            t.pop();
            t.push(value);
            t.push(tem);
        }
    }
    void pop() {
        int tem = s.top();
        s.pop();
        if(tem == t.top())t.pop();
        else{
            int m = t.top();
            t.pop();
            t.pop();
            t.push(m);
        }
    }
    int top() {
        return s.top();
    }
    int min() {
        return t.top();
    }
};