#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    string a;
    int b,f;
    double c,ed;
    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=="Standard"&&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==1){
        e=c*50;
        cout<<fixed<<setprecision(2)<<e<<endl;
    }
    else if(a=="Premium"&&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;
    }
    return 0;
}