S = input() l = len(S); S += '+OOOXXX' e = S.find('OOO') w = S.find('XXX') if e >l and w >l: print('NA') elif e < w: print('East') else: print('West')