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