#include <iostream> using namespace std; int main(){ int t,m; char s; cin>>t>>s; if(t<=1000) m=8; else{ m=8+(t-1000)/500*4; if(m%500!=0) m+=4; } if(s=='y') m+=5; cout<<m; return 0; }