S = input() O = S.find('OOO') X = S.find('XXX') print(O, X) if O == -1 and X == -1: print('NA') elif O == -1: print('West') elif X == -1: print('East') elif O > X: print('West') elif X > O: print('East')