B2048
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int kg,he=8;
bool jj;
cin>>kg>>jj;
if(jj=='y')
{
he=he+5;
}
if(kg>1000)
{
kg=kg-1000;
he=he+(kg/500)*4;
if(kg%500!=0)
{
he=he+4;
}
}
if(kg<=1000)
{
he=he+5;
}
cout<<he;
return 0;
}