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