#include<bits/stdc++.h> using namespace std; int main() { int x,y; char a; cin>>x>>a; y=x%500; if(y!=0) { x=x/500+1; } if(a==121) { cout<<x*8+5; } else { cout<<x*8; } return 0; }