x=input().split( ) s=int(x[0]) b=8 while s<=1000: if x[1]=='y': b+=5 while s>1000: i=(s-1000)//500+1 if x[1]=='y': b+=5 b+=4i else: b+=4i print(b)