#include <stdio.h>
#include <string.h>

#define MAX 5   // stack capacity

int main() 
{
    int n;
    scanf("%d", &n);

    int stack[MAX];
    int top = -1;

    for (int i = 0; i < n; i++) {
        char command[10];
        scanf("%s", command);

        if (strcmp(command, "push") == 0) {
            int x;
            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]);
            }
        } 
        else
        { 
        
    }

    return 0;
}