text = input() x = text.find('XXX') o = text.find('OOO') if x > -1 and o > -1: if x < o: print("West") else: print("East") elif x > -1 or o > -1: if x > -1: print("West") else: print("East") elif x == -1 and o == -1: print("NA")