a=input();l=a.find('OOO');r=a.find('XXX');p=print;w="West";e="East" if l==-1and-1!=r:p(w) elif r==-1and-1!=l:p(e) else:p(["NA",e,w][(l>r)+(l!=r)])