s = input() o = s.find("OOO") x = s.find("XXX") if o == x: print("NA") elif o < x: print("East") else: print("West")