#include<bits/stdc++.h>
using namespace std;
int main()
{
long long x,y;
char c;
cin>>x>>c;
if(x<=1000)
{
if(c=='n')
{
cout<<"8";
}
else
{
cout<<"13";
}
}
if(x>1000)
{
if((x-1000)%500!=0)
{
if(c=='n')
{
cout<<((x-1000)/x+1)*4+8;
}
else
{
cout<<((x-1000)/x+1)*4+13;
}
}
}
}