import java.util.Scanner; public class No_486 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); int O = 0; int X = 0; for (int i = 1; i <= s.length(); i++) { String s2 = s.substring(i - 1, i); if (s2.equals("O")) { O++; X = 0; } else if (s2.equals("X")) { X++; O = 0; } if(O >= 3 || X >= 3){ break; } } if (O == 3) { System.out.println("East"); } else if (X == 3) { System.out.println("West"); } else { System.out.println("NA"); } } }