// editor1
#include<stdio.h>
#include<string.h>
#define MAX 5
int stack[MAX];
int top = - 1;
const char*STACK_OVERFLOW_MSG="Stack overflow\n";
const char*STACK_EMPTY_MSG="Stack is empty\n";
const char*INVALID_INPUT_MSG="Stack Invalid input\n";
void push(int x)
{
 if(top== MAX - 1){
     printf("Stack overflow"); 
 } 
 else{
    stack[++top]=x;  
 }
}
    


void peek(){
if(top== -1){
    printf("Stack is empty");
    
}
else{
    printf("%d\n",stack[top]);
}
}
int is_valid_intger(const char*str){
    char* endptr;
strtol(str, &endstr,10);
return  *endptr=='\0'
    
    
}
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,"peek")==0){
        int x;
    scanf("%d",&x);
      peek(x);   
     }
}
    return 0;
}