l, S = map(str, input().split()) A = [390,429,468,507,546] L = int(l) if S == "Beat": L += 1 print(A[L-1])