#include <bits/stdc++.h>
using namespace std;
int main() {
  double hh, mm, h, d, c, n;
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  double x = ceil(h / n);
  double tc = c * x * 0.80;
  if (hh >= 20) {
    cout << tc << endl;
  } else {
    double t = (60 - mm) + (19 - hh) * 60;
    double th = t * d + h;
    double y = ceil(th / n);
    double tc1 = c * y * 0.80;
    double tc2 = c * x;
    cout << fixed << setprecision(4) << min(tc2, tc1) << endl;
  }
  return 0;
}
