#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <windows.h>
int stack[201];
int tops=0;
void push(int X) {
stack[tops] = X;
tops++;
}
int top() {
if(tops==0){
printf("-1\n");
}
else{
printf("%d\n",stack[tops]);
}
}
void pop() {
tops--;
stack[tops] = 0;
}
void size() {
printf("%d\n",tops);
}
void empty() {
if(tops==0){
printf("true");
}
else{
printf("false");
}
}
int main() {
int N;
char commends[201][10];
scanf("%d",&N);
for(int i=0;i<=N;i++) {
gets(commends[i]);
}
for(int i=0;i<N;i++){
if(commends[i][0] == 'p' || commends[i][1] == 'u'){ //push
int num=commends[i][7];
push(num);
}
else if(commends[i][0] == 't'){ //top
top();
}
else if(commends[i][0] == 'p' || commends[i][1] == 'o') { //pop
pop();
}
else if(commends[i][0] == 's') { //size
size();
}
else if(commends[i][0] == 'e') { //empty
empty();
}
}
return 0;
}