#include <iostream>
#include <cmath>
using namespace std;
int main (){
int x;
char c;
cin >> x >> c;
if(x<=1000 && c==110){
cout << 8;
}else if (x>1000 && c==110 && x%500!=0){
cout << 8+ceil(1.0*x/500)*4;
}else if (x>1000 && c==121 && x%500!=0){
cout << 8+ceil(1.0*x/500)*4+5;
}else if(x>1000 && c==121 && x%500==0){
cout << 8+x/500*4+5;
}else if (x<=1000 && c==121){
cout << 8+5;
}else if (x>1000 && c==110 && x%500==0){
cout << 8+x/500*4;
}
return 0;
}