#include using namespace std; int main() { std::ios_base::sync_with_stdio(false); while(!cin.eof()) { int dim; char fig; cin >> dim; if(cin.eof()) break; cin >> fig; if(fig == 'K') { if(dim == 1) cout << 1; else cout << 4; } else if(fig == 'N') { if(dim < 3) cout << 1; else cout << 3; } else if(fig == 'B') { cout << dim; } else { cout << dim; } cout << endl; } return 0; }