#include #include using namespace std; int main() { int n; char t; //char board[1000][1000]; while (scanf("%d %c", &n, &t) > 0) { if (t == 'K') { printf("%d\n", n == 1 ? 1 : 4); continue; } else if (t == 'N') { printf("%d\n", n == 1 || n == 2 ? 1 : 3); continue; } else if (t == 'B') { printf("%d\n", n); continue; } else if (t == 'R') { printf("%d\n", n); continue; } /* for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { board[x][y] = 0; } } int team = 1; for ( ; ; team++) { bool hasZero = false; for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { if (board[x][y] != 0) continue; bool canPlace = true; if (t == 'K') { for (int px = x - 1; px <= x + 1; px++) { for (int py = y - 1; py <= y + 1; py++) { if (px == x && py == y) continue; if (px < 0 || px >= n) continue; if (py < 0 || py >= n) continue; if (board[px][py] == team) canPlace = false; } } } else if (t == 'N') { for (int px = x - 5; px <= x + 5; px++) { for (int py = y - 5; py <= y + 5; py++) { if (px == x && py == y) continue; if (px < 0 || px >= n) continue; if (py < 0 || py >= n) continue; if (abs(x - px) * abs(y - py) != 2) continue; if (board[px][py] == team) canPlace = false; } } } if (canPlace) board[x][y] = team; else hasZero = true; } } if (!hasZero) break; } printf("%d\n", team); */ } return 0; }