s = input() to, se = (1000 if i == -1 else i for i in (s.find('OOO'), s.find('XXX'))) if to == se: print("NA") elif to < se: print("East") else: print("West")