import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Chessboard {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        String line;
        while ((line = br.readLine()) != null) {
            String[] parts = line.split(" ");
            int s = Integer.parseInt(parts[0]);
            String c = parts[1];

            if (c.equals("K")) {
                if (s == 1) {
                    System.out.println(1);
                }
                else {
                    System.out.println(4);
                }
            } else if (c.equals("N")) {
                System.out.println((s < 3) ? 1 : 2);
            } else {
                System.out.println(s);
            }
        }

        br.close();
    }
}
