#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int hh, mm;
  cin >> hh >> mm;
  double h, d, c, n;
  cin >> h >> d >> c >> n;
  double h1, bn, cost, bn2, cst;
  if (hh >= 20) {
    bn = (ceil)(h / n);
    cost = 0.80 * c * bn;
    cout << fixed << setprecision(4) << cost;
  } else {
    hh = 19 - hh;
    mm = 60 - mm;
    mm = hh * 60 + mm;
    h1 = h + d * mm;
    bn = (ceil)(h1 / n);
    cost = 0.80 * c * bn;
    bn2 = (ceil)(h / n);
    cst = bn2 * c;
    if (cst < cost)
      cout << fixed << setprecision(4) << cst;
    else
      cout << fixed << setprecision(4) << cost;
  }
}
