#include using namespace std; typedef long long ll; typedef pair P; #define REP(i,n) for(ll i=0;i v={0,390,429,468,507,546}; ll L; string S; cin >> L >> S; if(S=="Beat") cout << v[L+1] << endl; else cout << v[L] << endl; return 0; }