#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i) int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int L; string S; cin >> L >> S; vector ans = {390, 429, 468, 507, 546}; if (S == "Beat") cout << ans[L] << '\n'; else cout << ans[L - 1] << '\n'; }