import sys
def solve():
    try:
        line=sys.stdin.readline()
        if not line:
            return
        n=int(line.strip())
    except ValueError:
        return
    
    stack=[]
    for _ in range(n):
        line=sys.stdin.readline().strip()
        if not line:
            continue
        parts=line.split()
        command=parts[0]

        if command=="push":
            x=int(parts[1])
            stack.append(x)

        elif command=="pop":
            if stack:
                stack.pop()
            else:
                print("Empty")

        elif command=="query":
            if stack:
                print(stack[-1])
            else:
                print("Empty")
        elif command=="size":
            print(len(stack))

if __name__=="__main__":
    solve()