#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, h, rt, hc, n, hc1;
  double dc, cost, s1, s2;
  cin >> h >> m;
  cin >> hc >> dc >> cost >> n;
  s1 = (hc / n) * cost;
  if ((hc / n) * n < hc) s1 = s1 + cost;
  if (h < 20) {
    rt = (20 - h - 1) * 60 + (60 - m);
    hc1 = hc + (rt * dc);
    s2 = (hc1 / n) * ((double)cost * 0.8);
    if ((hc1 / n) * n < hc1) s2 = s2 + ((double)cost * 0.8);
    cout << min(s1, s2);
  } else {
    cout << (double)s1 * 0.8;
  }
  return 0;
}
