#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm;
  cin >> hh >> mm;
  int H, D;
  cin >> H >> D;
  int C, N;
  cin >> C >> N;
  double fir, sec;
  if (H % N == 0)
    fir = H / N * C;
  else
    fir = (H / N + 1) * C;
  if (hh >= 20) {
    fir *= 0.8;
    cout << fixed << setprecision(4) << fir;
    return 0;
  }
  int nH = H + D * ((20 - hh - 1) * 60 + 60 - mm);
  if (nH % N == 0)
    sec = nH / N * C;
  else
    sec = (nH / N + 1) * C;
  sec *= 0.8;
  cout << fixed << setprecision(4) << (fir < sec ? fir : sec);
  return 0;
}
