#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> vc;
    while (n--) {
        string s;
        cin >> s;
        if (s == "push") {
            int a;
            cin >> a;
            vc.push_back(a);
        }else if (s == "pop") {
            if(vc.empty()){
                cout << "Empty" << endl;
            }else{
                vc.pop_back();
                // cout << vc.back() << endl;
            }
        }else if (s == "query") {
            if(vc.empty()){
                cout << "Empty" << endl;
            }else{
                cout << vc.back() << endl;
            }
        }else if (s == "size") {
            cout << vc.size() << endl;
        }
    }
    // int a, b;
    // while (cin >> a >> b) { // 注意 while 处理多个 case
    //     cout << a + b << endl;
    // }
}
// 64 位输出请用 printf("%lld")