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