#include using namespace std; typedef long long int ll; typedef double ld; typedef pair ii; typedef vector vi; typedef vector vii; #define PB push_back #define FOR(prom, a, b) for ( ll prom = (a); prom < (ll)(b); ++prom ) #define F(a) FOR(i,0,a) #define FF(a) FOR(j,0,a) #define EPS (1e-10) int main () { ios::sync_with_stdio(false); ll S; char C; while ( cin >> S >> C ) { switch ( C ) { case 'R': case 'B': cout << S << endl; break; case 'K': cout << ( S == 1 ? 1 : 4 ) << endl; break; case 'N': cout << ( S <= 2 ? 1 : 2 ) << endl; break; } } return 0; }