#include <bits/stdc++.h>
using namespace std;
double moment(double hh, double mm, double H, double D, double C, double N) {
  double pm, nm;
  nm = ceil(H / N);
  pm = C * nm;
  return pm;
}
double twenty(double hh, double mm, double H, double D, double C, double N) {
  double t, pt, nt;
  if (hh < 20) {
    hh = hh * 60 + mm;
    t = 1200 - hh;
    H = H + t * D;
  }
  nt = ceil(H / N);
  pt = C * 0.8 * nt;
  return pt;
}
int main() {
  double hh, mm, H, D, C, N;
  cin >> hh >> mm >> H >> D >> C >> N;
  double pm{moment(hh, mm, H, D, C, N)}, pt{twenty(hh, mm, H, D, C, N)};
  if (hh >= 20) {
    cout << std::fixed << std::setprecision(4) << pt;
  } else if (pt > pm) {
    cout << std::fixed << std::setprecision(4) << pm;
  } else {
    cout << std::fixed << std::setprecision(4) << pt;
  }
  return 0;
}
