#include <stdio.h>
#include<stdlib.h>
int main() {
int *stack=(int *)malloc(40000000);
int top=-1;
int n;
scanf("%d",&n);
while(n--){
char op[10];
scanf("%s",op);
if(op[0]=='p'&&op[1]=='u'){
int x;
scanf("%d",&x);
stack[++top]=x;
}else if(op[0]=='p'){
if(top==-1) printf("Empty\n");
else top--;
}
else if(op[0]=='q'){
if(top==-1) printf("Empty\n");
else printf("%d\n",stack[top]);
}
else if(op[0]=='s'){
printf("%d\n",top+1);
}
}
return 0;
}

京公网安备 11010502036488号