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