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