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