#include <bits/stdc++.h>
using namespace std;
stack<int>a;
string order;
int t;
int main() {
scanf("%d",&t);
while(t--){
cin>>order;
if(order == "push"){
int x;
scanf("%d\n",&x);
a.push(x);
}
else if(order == "pop"){
if(a.empty())printf("Empty\n");
else a.pop();
}
else if(order == "query"){
if(a.size() == 0)printf("Anguei!\n");
else printf("%d\n",a.top());
}
else printf("%d",a.size());
int x = a.size();
while(x--)a.pop();
}
return 0;
}