S = input() east_index = S.find('OOO') west_index = S.find('XXX') if east_index >= 0 and west_index >= 0: print('East' if east_index < west_index else 'West') else: print('East' if east_index >= 0 else 'West' if west_index >= 0 else 'NA')