a=int(input()) b=input() if a>1000: a=a-1000 a=a//500+1 else: a=0 if b=="n": b=0 else: b=5 print(8+a+b)