s = input() i,j = None, None if 'OOO' in s: i=s.index('OOO') if 'XXX' in s: j = s.index('XXX') if (i is None) and (j is None): print('NA') elif (i is None) and j!=None: print('West') elif i!=None and (j is None): print('East') else: if i