#include<bits/stdc++.h>
using namespace std;
stack<int> a;
int main(){
    int n;
    cin>>n;
    while(n--){
        string op;
        cin>>op;
    if(op=="push"){
    int x;
    cin>>x;
    a.push(x);
    }
    else if(op=="pop"){
      if(!a.empty()){
        a.pop();
      }
      else cout<<"Empty"<<endl;
    }
    else if(op=="size"){
        cout<<a.size()<<endl;
    }
    else if(op=="query"){
       if(!a.empty()){
        cout<<a.top()<<endl;
      }
      else cout<<"Empty"<<endl;
    }}
    return 0;
}