#include #include int main() { int s; char c; while (1) { if (scanf("%d %c", &s, &c) != 2) break; if (c == 'K') { if (s > 1) printf("4\n"); else printf("1\n"); } if (c == 'N') { if (s > 2) printf("2\n"); else printf("1\n"); } if ((c == 'B') || (c == 'R')) { printf("%d\n", s); } scanf("%c", &c); } return 0; }