MOD = 998244353 def II(): return int(input()) def LI(): return list(input()) def LMI(): return list(map(int, input().split())) def LMS(): return list(map(str, input().split())) def LLMI(x): return [list(map(int, input().split())) for _ in range(x)] def LLMS(x): return [list(input()) for _ in range(x)] def execute(): l, s = input().split() l = int(l) if s == 'Beat': l += 1 if l == 1: print(390) elif l == 2: print(429) elif l == 3: print(468) elif l == 4: print(507) elif l == 5: print(546) if __name__ == "__main__": T = 1 for _ in range(T): execute()