/*
import java.util.*;
public class Main{
public Main() {
Scanner scan = new Scanner(System.in);
String input = scan.nextLine();
String [] sp1 = input.split(" ");
int[] st = new int[200];
int top=0;
char[] op = new char[2000];
int opTop=0;
for(int i=0; i<sp1.length; i++) {
if(sp1[i].equals("+") ||sp1[i].equals("-") || sp1[i].equals("*")) {
if(opTop==0) { //연산자가 처음으로 들어올때
op[opTop++] = sp1[i].charAt(0);
}
else if(op[opTop-1]=='*'){ // 그 전에 들어가 있는 것이 *일때
if(sp1[i].charAt(0)=='+'||sp1[i].charAt(0)=='-') {
//그 후에 들어올 것이 +-일때
op[opTop-1] = sp1[i].charAt(0);
top--;
int b = st[top];
st[top] = 0;
top--;
int a = st[top];
st[top] = 0;
int c = a*b;
st[top] = c;
top++;
}else if(sp1[i].charAt(0)=='*') {
//그 후에 들어올 것이 *일때
op[opTop-1]=sp1[i].charAt(0);
opTop++;
}
}
else{
op[opTop-1]=sp1[i].charAt(0);
}
}else {
st[top]=Integer.valueOf(sp1[i]);
top++;
}
}
for(int i=opTop-1; i>=0; i--) {
if(op[i]=='*') {
top--;
int b = st[top];
top--;
int a = st[top];
int c =a*b;
st[top]=c;
top++;
}
else if(op[i]=='+') {
top--;
int b = st[top];
top--;
int a= st[top];
int c= b+a;
st[top]=c;
top++;
}else {
top--;
int b = st[top];
top--;
int a= st[top];
int c= b-a;
st[top]=c;
top++;
}
}
System.out.println(st[0]);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.util.*;
public class Main{
public Main() {
Scanner scan = new Scanner(System.in);
String input = scan.nextLine();
String [] sp1 = input.split(" ");
int[] st = new int[200];
int top=0; //data가 들어갈 위치
for(int i=0; i<sp1.length; i++) {
if(sp1[i].equals("+") ||sp1[i].equals("-") || sp1[i].equals("*")) {
if(sp1[i].equals("+")) {
int b= st[--top];
int a = st[--top];
st[top++]=b+a;
}else if(sp1[i].equals("-")) {
int b= st[--top];
int a = st[--top];
st[top++] = a-b;
}else{
int b= st[--top];
int a = st[--top];
st[top++]=b*a;
}
}
else {
st[top++]=Integer.valueOf(sp1[i]);
}
}
System.out.println(st[top-1]);
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.util.*;
class intStack{
int max;
int ptr;
int[] stk;
public intStack(int capacity) {
ptr = 0;
max = capacity;
try {
stk= new int[max];
}
catch(OutOfMemoryError e) {
max =0;
}
}
public void push(int x) {
if(ptr>=max) {
throw new OverflowIntStackException();
}
stk[ptr++] = x;
}
public class OverflowIntStackException extends RuntimeException{
public OverflowIntStackException() {
}
}
public void finish() {
for(int i=ptr-1; i>=0; i--) {
if(i%3==2)
System.out.print(',');
System.out.print(stk[i]);
}
}
}
public class Main{
Scanner scan = new Scanner(System.in);
public Main() {
int n= 8;
//int n = scan.nextInt();
intStack s = new intStack(n);
String arr = scan.nextLine();
char[] arr1 = new char[n];
arr1 = arr.toCharArray();
for(int i=0; i<n; i++) {
//System.out.println(arr1[i]);
s.push(Character.getNumericValue(arr1[i]));
}
s.finish();
}
public static void main(String[] args) {
new Main();
}
}
*/
import java.util.*;
class IntStack{
int ptr;
int max;
int[] stk;
public IntStack(int capacity) {
ptr=0;
max=capacity;
try {
stk = new int [max];
}catch(OutOfMemoryError e) {
max=0;
}
}
public class OverflowIntStackException extends RuntimeException{
public OverflowIntStackException() {
}
}
public class EmptyIntStackException extends RuntimeException{
public EmptyIntStackException() {
}
}
public int push(int x) throws OverflowIntStackException {
if(ptr>=max) {
throw new OverflowIntStackException();
}
return stk[ptr++]=x;
}
public int pop() throws EmptyIntStackException{
if(ptr<=0) {
throw new EmptyIntStackException();
}
return stk[--ptr];
}
public int top() {
if(ptr==0)
return -1;
return stk[ptr-1];
}
public boolean empty() {
if(ptr==0)
return true;
return false;
}
public int size() {
return max;
}
}
public class Main{
public Main() {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
IntStack s = new IntStack(n);
for(int i=0; i<n; i++) {
String input = scan.nextLine();
String [] sp1 = input.split(" ");
if(sp1[0].equals("push("))
{
s.push(Integer.valueOf(sp1[1]));
}
else if(sp1[0].equals("pop()"))
{
s.pop();
}
else if(sp1[0].equals("top()"))
{
s.top();
}
else if(sp1[0].equals("size()"))
{
s.size();
}
else
{
s.empty();
}
}
}
public static void main(String[] args) {
new Main();
}
}