#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int hh, mm;
  cin >> hh >> mm;
  int h, d, c, n;
  cin >> h >> d >> c >> n;
  if (hh < 20) {
    int extra = 0;
    int time = (20 - hh - 1) * 60 + 60 - mm;
    extra = time * d;
    cout << min(c * ((ceil)(1.0 * h / n)),
                0.8 * c * ((ceil)(1.0 * (h + extra) / n)));
  } else {
    cout << 0.8 * c * ((ceil)(1.0 * h / n));
  }
  return 0;
}
