S = input() o = S.find('OOO') x = S.find('XXX') if o < 0: o = 99 if x < 0: x = 99 if o < x: print('East') elif x < o: print('West') else: print('NA')