s = input() if 'OOO' not in s: if 'XXX' not in s: print('NA') else: print('West') exit() if 'XXX' not in s: print('East') exit() a = s.index('OOO') b = s.index('XXX') if a < b: print('East') else: print('West')