#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main()
{
int x,v,e;
string a;
cin>>x>>a;
e=x-1000;
if(x<=1000 && a=="y") v=8+5;
else if(x<=1000 && a=="n") v=8;
else if(x>1000 && a=="y" && e<500) v=8+4*1+5;
else if(x>1000 && a=="y" && e>=500) v=8+4*((x-1000)/500)+5;
else if(x>1000 && a=="n" && e<500) v=8+4*1;
else if(x>1000 && a=="n" && e>=500) v=8+4*((x-1000)/500);
cout<<v;
return 0;
}