import java.util.*; class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { String s = sc.next(); //x=West o=East int w = s.indexOf("XXX"); int o = s.indexOf("OOO"); // System.out.println(w+":"+o); if (w==-1 && o==-1) System.out.println("NA"); else if (w==-1 && o>=0) System.out.println("East"); else if (w>=0 && o==-1) System.out.println("West"); else System.out.println(w