/*#include <stdio.h>
#include<string.h>
int top=0,sum=0;
char str[100000]={};
int main()
{
int i,n,s,a;
scanf("%s",str);
for(i=0;str[i]!=NULL;i++)
{
if(str[i]=='(')
{
if(str[i+1]==')')
{
sum+=top;
}
else
{
top+=1;
}
}
else if(str[i]==')')
{
if(str[i-1]=='(')
{
}
else
{
top-=1;
sum+=1;
}
}
}
printf ("%d",sum);
return 0;
}
//top : 놓여있는 막대의 갯수
//
//sum : 총 조각의 갯수
*/
#include<stdio.h>
int stack[500]={};
int top=-1;
int main()
{
int i, n,x,j,g=0;
char str[50]={};
scanf("%d ",&n);
for(i=0;i<n;i++)
{
gets(str);
if(str[0]=='p')
{
if(str[1]=='u')
{
x=
top++;
stack[top]=x;
}
else if(str[1]=='o')
{
if(top!=-1)
{
top--;
}
}
}
else if(str[0]=='t')
{
if(stack [top]==-1)
{
printf("-1\n");
}
else
{
printf("%d\n",stack[top]);
}
}
else if(str[0]=='s')
{
printf("%d\n",top+1);
}
else if(str[0]=='e')
{
if(top!=-1)
{
printf("true\n");
}
else
{
printf("false\n");
}
}
}
return 0;
}



