while 1: s=[];p=e=0;i=raw_input() for c in i: b=")]}>([{".find(c) if b/4:s+=[b%4] elif b%4-s.pop():e=i[p:];break p+=1 print(s or e)and"failed at: "+(e or"EOL")or"yes"