R=[390,429,468,507,546] L,S=input().split() L=int(L) if S=="Action" or S=="Try": print(R[L-1]) elif S=="Beat": print(R[L])