i=input() x,y=i.find("OOO"),i.find("XXX") print("NA" if x==y==-1 else "East" if -1