#include<iostream> using namespace std; int main() { int wei,a; char qui; cin>>wei>>qui; if(wei<=1000) a=8; else a=int((wei+499)/500)*4; if(qui=a) a+=5; cout<<a; }