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