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