// editor1
#include<stdio.h>
#include<string.h>
#define MAX 5
int stack[MAX];
int top = - 1;
void push(int x)
{
 if(top== MAX - 1){
     printf("stack is full"); 
 } 
 else{
    stack[++top]=x;  
 }
}
    


void peek(){
if(top== -1){
    printf("stack is empty");
    
}
else{
    printf("%d",stack[top]);
}
}
int main(){
   
   int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
    char cmd[10];
    scanf("%s",cmd);
    if(strcmp (cmd,"push")==0){
     int x;
    scanf("%d",&x);
    push(x);   
    }
    else if(strcmp (cmd,"push")==0){
      peek(x);  
    }
    
}