n=int(input())
l=[]
for i in range(n):
    s=input().split()
    if s[0]=='push':
        l.append(s[1])
    elif s[0]=='pop':
        if len(l)!=0:
            l.pop()
        else:
            print('Empty')
    elif s[0]=='query':
        if len(l)!=0:
            
            print(l[len(l)-1])
        else:
            print('Empty')
    elif s[0]=='size':
        print(len(l))