L, S = input().split() atk = [390,429,468,507,546] print(atk[int(L) - 1 + (S == "Beat")])