#include <iostream>
using namespace std;
int stack[200];
int top=-1;
void push(int x){
stack[++top] = x;
}
int f_top(){
if(top!=-1){
return stack[top];
}
else{
return -1;
}
}
void pop(){
if(top!=-1){
top--;
}
}
bool empty(){
if(top==-1){
return true;
}
else{
return false;
}
}
int main(){
int n;
cin >> n;
string q,s;
char t;
for(int i=0;i<n;i++){
cin >> q;
s = q.substr(0,4);
if(s=="push"){
int x;
cin >> x;
cin >> t;
push(x);
}
else if(s=="top("){
cout << f_top() << "\n";
}
else if(s=="pop("){
pop();
}
else if(s=="size"){
cout << top+1 << "\n";
}
else{
if(empty()){
cout << "true" << "\n";
}
else{
cout << "false" << "\n";
}
}
}
}