#include <iostream>
using namespace std;
int main(){
long long x;
int c;
char a,b;
cin>>x>>a>>b;
if(a!='C'&&b=='B'||a=='B'&&b!='C'){
c=1.0*x*0.8;
cout<<c;
}else if(a!='B'&&b=='C'||a=='C'&&b!='B'){
c=1.0*x*0.7;
cout<<c;
}else if(a=='C'&&b=='B'||a=='B'&&b=='C'){
c=1.0*x*0.6;
cout<<c;
}else if(a=='A'&&b=='A'){
cout<<x;
}
return 0;
}