s = input() a = s.find('OOO') b = s.find('XXX') if a < 0: a = 99 if b < 0: b = 99 if a > b: print('West') elif a < b: print('East') else: print('NA')