#include<stdio.h>
#include<string.h>
#define MAX 100;

int stack[MAX];
int top=-1;
int size;
void push(int x){
    if(top==size-1){
        printf("Stack is overflow");
    }
    stack[++top]=x;
}
void pop(){
    if(top==-1){
        printf("Stack is underflow");
        return;
    }
    top--;
}
void display(){
    if(top==-1){
        printf("Stack underflow");
    }
    for(int i=0;i<=top;i++){
        printf("%d",stack[i]);
    }
}
void peek(){
    if(top==-1){
        printf("Stack underflow");
    }
    printf("%d",stack[top]);
}
int main(){
    int size;
    scanf("%d",&size);
    char str[20];
    for(int i=0;i<size;i++){
        if(strcmp(str,"PUSH")==0){
            int x;
            scanf("%d",&x);
            push(x);
        }
        else if(strcmp(str,"POP")==0){
            pop();
        }
        else if(strcmp(str,"PEEK")==0){
            peek();
        }
    }
    return 0;
}