#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm;
  cin >> hh >> mm;
  int h, d, c, n;
  cin >> h >> d >> c >> n;
  int leftTime = (60 - mm) + (20 - hh - 1) * 60;
  if (hh >= 20 && hh <= 23) {
    float cost = h / n + (h % n != 0);
    cost = cost * c * 0.8;
    cout << fixed << setprecision(4) << cost << endl;
    return 0;
  } else {
    float buns = h / n + (h % n != 0);
    h = (d * leftTime) + h;
    float bun = h / n + (h % n != 0);
    float cost = buns * c;
    float costs = bun * c * .8;
    if (cost >= costs)
      cout << fixed << setprecision(4) << costs << endl;
    else {
      cout << fixed << setprecision(4) << cost << endl;
    }
  }
}
