#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long double hrs, min_, hunger, inc_hunger, food_price, dec_hunger;
  cin >> hrs >> min_;
  cin >> hunger >> inc_hunger >> food_price >> dec_hunger;
  long double time = hrs * 60 + min_;
  if (time > 1200) time = 1200;
  long double price_after_20 = (food_price * 4) / 5;
  long double hunger_after_20 = hunger + inc_hunger * (1200 - time);
  long double p1 = ceil(hunger / dec_hunger) * food_price,
              p2 = ceil(hunger_after_20 / dec_hunger) * price_after_20;
  cout << fixed << setprecision(4) << min(p1, p2);
  cout << "\n";
  return 0;
}
