#include #include using namespace std; int solve(int size, char c) { if(c=='B' || c=='R') return size; if(c=='N') { if(size < 3) return 1; else return 2; } if(c=='K') { if(size<3) return size*size; else return 9; } } int main(void) { int size; char c; while(scanf("%d %c",&size,&c) != EOF) { cout << solve(size, c) << endl; } return 0; }