import math a=input().split(" ") x=int(a[0]) y=str(a[1]) q=0 if x>1000: q+=8 q+=math.ceil((x-1000)/500)*4 else: q+=8 if y=="y": q+=5 print(q)