def f(c,*s): if'if'!=c:return c,s p,s=f(*s) q,s=f(*s[1:]) r,s=f(*s[1:]) return[r,q][p>'s'],s while True: print(f(*input().split())[0])