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