#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    string a;
    int b,f;
    double c,e,d;
    cin>>a>>b>>c;
    if(!(b==0|| b==1)){
        cout<<"Invalid input";
        return 0;
    }
    if(!(a=="Basic"|| a=="Standard"||a=="Premium")){
        cout<<"Invalid input";
        return 0;
    }
    if(a=="Basic"&&b==1){
        e=(c*30)-(c*6);
        cout<<fixed<<setprecision(2)<<e<<endl;
    }
    else if(a=="Basic"&&b==0){
        e=c*30
        cout<<fixed<<setprecision(2)<<e<<endl;
    }
    else if(a=="Standard"&& b==1){
        e=(c*50)-(c*10);
        cout<<fixed<<setprecision(2)<<e<<endl;
    }
    else if(a=="Standard"&& b==0){
        e=c*50;
        cout<<fixed<<setprecision(2)<<e<<endl;
    }
    else if("Premimum" && b==1){
        e=(c*80)-(c*16);
        cout<<fixed<<setprecision(2)<<e<<endl;
    }
    else if(a=="Premium" && b==0){
        e=c*80;
        cout<<fixed<<setprecision(2)<<e<<endl;
    }
}