li = input() e, w = li.find('OOO'), li.find('XXX') if e == -1 and w == -1: print('NA') elif e == -1 and w >0: print('West') elif e >0 and w == -1: print('East') else: if e < w: print('East') else: print('West')