def solve(): s = input() east_3win = s.find("OOO") west_3win = s.find("XXX") if east_3win >= 0 and east_3win < west_3win: print("East") elif west_3win >= 0 and west_3win < east_3win: print("West") else: print("NA") if __name__=="__main__": solve()