import re s = input() if re.search(r'OOO',s) and re.search(r'XXX',s): m = re.search(r'OOO',s) n = re.search(r'XXX',s) if m.start() > n.start(): print("West") else: print("East") elif re.search(r'OOO',s): print("East") elif re.search(r'XXX',s): print("West") else: print("NA")