S = input() e = S.find("OOO") w = S.find("XXX") if e == w == -1: print("NA") elif e == -1 or e > w > -1: print("West") else: print("East")