s=input() winner="NA" east_o=0 west_x=0 for i in s: if i=="O": east_o+=1 west_x=0 if i=="X": west_x+=1 east_o=0 if 3<=east_o: winner="EAST" break if 3<=west_x: winner="WEST" break print(winner)