#include using namespace std; int main () { int A[] = {390,429,468,507,546}; int n; string s; cin >> n >> s; cout << A[n - (s != "Beat")] << endl; }