#python 3.5.2 S = input() x, o = [0, 0] for Si in S: if Si == 'X': x += 1 o = 0 if Si == 'O': x = 0 o += 1 if x == 3: print('West') break if o == 3: print('East') break if not (x == 3 or o == 3): print('NA')