#include #include using namespace std; int main(int argc, char** argv) { ios::sync_with_stdio(false); int S; char g; while(cin >> S >> g) { if (g == 'K') { if (S == 1) cout << 1 << endl; else cout << 4 << endl; } if (g == 'N') { if (S < 3) cout << 1 << endl; else cout << 2 << endl; } if (g == 'B') { cout << S << endl; } if (g == 'R') { cout << S << endl; } } return 0; }