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