S = input() e = S.find("OOO") w = S.find("XXX") if e == -1 and w == -1: print("NA") elif (e < w or w == -1) and e > -1: print("East") else: print("West")