/*
#include <stdio.h>
#include <string.h>
#define SIZE 101
int stack[SIZE];
int result[SIZE];
int top = -1, top1 = -1;
int n_1 = '0';
void push(int a)
{
top++;
stack[top] = a;
}
int pop()
{
return stack[top--];
}
void push1(int a)
{
top1++;
result[top] = a;
}
int pop1()
{
return result[top1--];
}
int main()
{
char num[SIZE];
char num1[SIZE];
int a, b, i, c, over = 0, n;
scanf("%s %s", num, num1);
a = strlen(num);
b = strlen(num1);
if(a>b)
{
c = a;
}
else
{
c = b;
}
if(c == a)
{
for(i=0; i<a; i++)
{
push(num[i]-n_1);
}
}
else
{
for(i=0; i<b; i++)
{
push(num1[i]-n_1);
}
}
if(a==c)
{
c=b;
}
else
{
c=a;
}
for(i=c-1; i>=0; i--)
{
if(c==b)
{
push1(pop()+num1[i]-n_1);
}
if(c==a)
{
push1(pop()+num[i]-n_1);
}
}
for(i=0; i<c; i++)
{
n = pop1()%10+over;
printf("%d", n);
over = n/10;
}
if(c==b)
{
a -= c;
}
if(c==a)
{
a = b - c;
}
for(i=0; i<a; i++)
{
n = pop1()%10+over;
printf("%d", n);
over = n/10;
}
}
*/
/*
#include <stdio.h>
#define SIZE 31
int stack[SIZE];
int top = -1;
void push(int a)
{
top++;
stack[top]=a;
}
int pop()
{
return stack[top--];
}
int main()
{
char str[SIZE];
int n, in=0, i, t;
scanf("%s", str);
for(i=0; i<SIZE; i++)
{
if(str[i]=='(')
{
push(-2);
}
else if(str[i]=='[')
{
push(-1);
}
else if(str[i]==')' || str[i]==']')
{
while(1)
{
n = pop();
if(n==-1 || n==-2)
{
if(str[i]==')' && n == -1)
{
printf("0");
return 0;
}
else if(str[i]=='[' && n == -2)
{
printf("0");
return 0;
}
if(in==0)
{
in=n+4;
}
else
{
in*=n+4;
}
break;
}
else
{
in+=n;
}
}
push(in);
in=0;
}
}
t = top;
for(i=0; i<=t; i++)
{
n = pop();
if(n<0)
{
printf("0");
return 0;
}
in+=n;
}
printf("%d", in);
return 0;
}
*/
#include <stdio.h>
#define SIZE 201
int stack[SIZE];
int top = -1;
void push(int a)
{
top++;
stack[top]=a;
}
int pop()
{
if(top==-1)
{
return 0;
}
return stack[top--];
}
int top_()
{
if(top==-1)
{
return -1;
}
return stack[top];
}
int size()
{
return top+1;
}
int empty()
{
if(top == -1)
{
return 1;
}
else
{
return 0;
}
}
int main()
{
int i, n, n1=0, a;
char str[SIZE];
scanf("%d ", &n);
for(i=0; i<n; i++)
{
gets(str);
if(str[0]=='p' && str[1]=='u')
{
a=6;
while(str[a]!=' ')
{
n1 = n1*10+str[a]-'0';
a++;
}
push(n1);
n1=0;
}
else if(str[0]=='t')
{
printf("%d\n", top_());
}
else if(str[0]=='p' && str[1]=='o')
{
pop();
}
else if(str[0]=='s')
{
printf("%d\n", size());
}
else if(str[0]=='e')
{
n1 = empty();
if(n1==1)
{
printf("true\n");
}
else
{
printf("false\n");
}
}
}
return 0;
}