import sys line = input() east = "OOO" west = "XXX" east_index = line.find(east) west_index = line.find(west) if east_index == -1 and west_index == -1: print("NA") sys.exit() if east_index == -1 and west_index != -1: print("West") sys.exit() if east_index != -1 and west_index == -1: print("East") sys.exit() if east_index > west_index: print("West") else: print("East")