#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm, h, d, c, n, nb;
  double c1, c2;
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  nb = ceil((double)h / n);
  if (hh >= 20) {
    cout << setprecision(5) << nb * c * 0.8;
  } else {
    c1 = (double)nb * c;
    int dur;
    dur = 60 - mm + (20 - hh - 1) * 60;
    h += dur * d;
    nb = ceil((double)h / n);
    c2 = (double)nb * c * 0.8;
    double c3 = min(c1, c2);
    cout << fixed << setprecision(5) << c3;
  }
  return 0;
}
