#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef struct Stack {
int date;
struct Stack* before;
struct Stack* end;
}Stack;
void push(Stack* head, int x) {
Stack* p = head->end;
Stack* s = (Stack*)malloc(sizeof(Stack));
s->date = x;
s->before = p;
s->end = NULL;
head->end = s;
head->date++;
}
void pop(Stack* head) {
Stack* p = head->end;
head->end = p->before;
head->date--;
free(p);
}
int query(Stack* head) {
Stack* p = head->end;
return p->date;
}
int size(Stack* head) {
return head->date;
}
void analysis(char* command, Stack* head) {
if (command[0] == 'p') {
if (command[1] == 'u') {
int i = 5;
int sum = 0;
int flag = 1;
if (command[i] == '-') {
i++;
flag = -1;
}
while (command[i] != '\0') {
sum = sum * 10 + command[i++] - 48;
}
push(head, flag * sum);
}
else if (command[1] == 'o') {
if (size(head) > 0) {
pop(head);
}
else {
printf("Empty\n");
}
}
}
else if (command[0] == 'q') {
if (size(head) > 0) {
printf("%d\n", query(head));
}
else {
printf("Empty\n");
}
}
else if (command[0] == 's') {
printf("%d\n", size(head));
}
else {
printf("输入错误");
}
}
int main() {
Stack head;
head.date = 0;
head.before = NULL;
head.end = &head;
int T = 0;
scanf("%d", &T);
char command[20];
while (T--) {
getchar();
scanf("%[^\n]", command);
analysis(command, &head);
}
return 0;
}