#include<stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX 5  // Maximum capacity of the stack

int stack[MAX];
int top = -1;

void push(int x) {
    if (top >= MAX - 1) {
        printf("Stack overflow\n");
    } else {
        top++;
        stack[top] = x;
    }
}

void peek() {
    if (top == -1) {
        printf("Stack is empty\n");
    } else {
        printf("%d\n", stack[top]);
    }
}

int main() {
    int n;
    scanf("%d");
    getchar();  // To consume newline after integer input

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        char command[10];
        int value;

        fgets(command, sizeof(command), stdin);

        if (strncmp(command, "push", 4) == 0) {
            sscanf(command + 5, "%d", &value);
            push(value);
        } else if (strncmp(command, "peek", 4) == 0) {
            peek();
        }
    }

    return 0;
}