/*
#include <stdio.h>
int queue[100000], fronttt=-1, backkk=-1;
void enqueue( int b )
{
backkk++;
queue[backkk]=b;
}
void dequeue()
{
if(fronttt==backkk)
{
return ;
}
fronttt++;
}
void front()
{
if(fronttt==backkk)
{
printf("-1\n");
}
else
{
printf("%d\n", queue[fronttt+1]);
}
}
void back()
{
if(fronttt==backkk)
{
printf("-1\n");
}
else
{
printf("%d\n", queue[backkk]);
}
}
void size()
{
printf("%d\n", backkk-fronttt);
}
void empty()
{
if(fronttt==backkk)
{
printf("true\n");
}
else
{
printf("false\n");
}
}
int main()
{
int a, b;
char arr[100];
scanf("%d", &a);
for(int i=1;i<=a;i++)
{
scanf("%s",arr);
if(arr[0]=='p' && arr[1]=='u')
{
scanf("%d )",&b);
enqueue(b);
}
else if(arr[0]=='p' && arr[1]=='o')
{
dequeue();
}
else if(arr[0]=='f')
{
front();
}
else if(arr[0]=='b')
{
back();
}
else if(arr[0]=='s')
{
size();
}
else
{
empty();
}
}
return 0;
}
*/
#include <stdio.h>
int s[100000]={}, topp=-1;
int push( int b )
{
topp++;
s[topp]=b;
}
void pop()
{
if(topp!=-1)
{
topp--;
}
}
void top()
{
if(topp==-1)
{
printf("-1\n");
}
else
{
printf("%d\n", topp);
}
}
void size()
{
printf("%d\n", topp+1);
}
void empty()
{
if(topp==-1)
{
printf("true\n");
}
else
{
printf("false\n");
}
}
int main()
{
int a, b;
char arr[100];
scanf("%d", &a);
for(int i=1;i<=a;i++)
{
scanf("%s", arr);
if(arr[0]=='p' && arr[1]=='u')
{
scanf("%d )", &b);
push(b);
}
else if(arr[0]=='t')
{
top();
}
else if(arr[0]=='p' && arr[1]=='o')
{
pop();
}
else if(arr[0]=='s')
{
size();
}
else
{
empty();
}
}
return 0;
}