# -*- coding: utf-8 -*- text = input() if 'OOO' in text: O_position = text.index('OOO') else: O_position = 1000 if 'XXX' in text: X_position = text.index('XXX') else: X_position = 1000 if O_position == X_position: print('NA') elif O_position < X_position: print('East') elif X_position < O_position: print('West')