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