#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
class fuel{
    protected:
      float quantity;
      float price;
    public:
      fuel(float q, float p) :quantity(q), price(p){}
      virtual void calculateCost() = 0;
};
class petrol : public fuel {
public:
  petrol (float q,float p) : fuel(q,p){}
      void calculateCost() override{
          if(quantity < 0 || price < 0){
              cout<<"invalid input"<<endl;
          }else{
              float totalCost = quantity * price;
              cout<<fixed<<setprecision(2)<<totalCost<<endl;
          }
      }
  
};
class Diesel : public fuel {
public:
  Diesel (float q,float p) : fuel(q,p){}
      void calculateCost() override{
          if(quantity < 0 || price < 0){
              couT<<"invalid input"<<endl;
          }else{
              float totalCost = quantity * price;
              cout<<fixed<<setprecision(2)<<totalCost<<endl;
          }
      }
  
};
int main()
{
    string fuelType;
    float  quantity, price;
    cin>>fuelType>>quantity >>price;
    
    fuel * fuel = nullptr;
    if (fuelType == "petrol"){
        fuel = new petrol(quantity,price);
        
    }else{
        fuel = new Diesel(quantity,price);
    }
    if(fuel){
        fuel->calculateCost();
        delete fuel;
    }else{
        cout<<"invlid input"<<endl;
    }
    return 0;
}