#include <bits/stdc++.h>
using namespace std;
double cost(double H, double C, double N) { return C * (double)ceil(H / N); }
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 ans, newC = (double)0.8 * C;
  if (hh < 20) {
    double newH = H + D * (20 * 60 - (hh * 60 + mm));
    ans = min(cost(H, C, N), cost(newH, newC, N));
  } else {
    ans = cost(H, newC, N);
  }
  cout << fixed << setprecision(4) << ans;
  return 0;
}
