#include<stdio.h>
#include<string.h>
int main()
{int m;
int M;
scanf("%d",&m);
if (m<=1000){
M = 1;
}else{M = 2;
}
int f;
switch(M)
{case 1:f = 8;
case 2:if(m%500==0){
f = 8 + ((m-1000)/500)*4;
break;
} else if(m%500!=0){
f = 8 + ((m-1000)/500+1)*4;
}
}
char x[256];
scanf("%s",&x);
if(strcmp(x,"y")==0){
f += 5;
}
else{f=f;
}
printf("%d",f);
return 0;
}