s = input() e = "OOO" w = "XXX" NO_STRAIGHT_WIN = 1000 def f(word, pat): win = word.find(pat) if win == -1: win = NO_STRAIGHT_WIN return win win_e = f(s, e) win_w = f(s, w) if win_e == NO_STRAIGHT_WIN and win_w == NO_STRAIGHT_WIN: ans = "NA" elif win_e < win_w: ans = "East" else: ans = "West" print(ans)