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