#include <bits/stdc++.h>
using namespace std;
int main() {
  double hh, mm;
  cin >> hh >> mm;
  cout << setprecision(10) << fixed;
  double h, d, c, n;
  cin >> h >> d >> c >> n;
  double req = ceil(h / n);
  double init_cost = req * c;
  double t_in_mins = 60 * hh + mm;
  double rem_time = (60 * 20 - t_in_mins);
  double fcost;
  if (rem_time > 0) {
    double nh = h + rem_time * d;
    fcost = ceil(nh / n) * c;
    fcost -= 0.2 * fcost;
    if (fcost < init_cost)
      cout << fcost << endl;
    else
      cout << init_cost << endl;
    return 0;
  } else {
    init_cost -= 0.2 * init_cost;
    cout << init_cost << endl;
    return 0;
  }
}
