n=int(input()) x=input() ans=8 if x == "y": ans=ans+5 if n >1000: ans = ans+(n-1000+499)//500*4 print(ans)