#include <stdio.h>
int main(){
int x,s,n,y; char c;
scanf("%d %c",&x,&c);
if(c=='y')
s=5;
if(c=='n')
s=0;
if(x<=1000)
s=s+8;
else if (x>1000)
{ s=s+8;
x=x-1000;
if(x%500!=0)
{
printf("%d",s=s+4*(x/500+1));
}
else
printf("%d",s=s+4*(x/500));
}
return 0;
}