#include #include using namespace std; //ios::sync_with_stdio(false); int main() { unsigned s = 0; while (cin >> s) { char t = 0; cin >> t; if (t == 'K') { if (s > 1) cout << 4; else cout << 1; } else if (t == 'N') { if (s>2) cout << 2; else cout << 1; } else if (t == 'B') { cout << s; } else if (t == 'R') { cout << s; } cout << endl; } }