#include <bits/stdc++.h>
using namespace std;
int run() {
  int hh = 0, mm = 0;
  cin >> hh >> mm;
  int H = 0, D = 0, C = 0, N = 0;
  cin >> H >> D >> C >> N;
  int sHH = 20, sMM = 0;
  int diffMM = sHH * 60 + sMM - hh * 60 - mm;
  if (diffMM < 0) diffMM = 0;
  int t1 = H + D * diffMM;
  int t2 = t1 / N;
  if (0 != (t1 % N)) t2++;
  double d3 = t2 * C * 0.8;
  int t3 = H / N;
  if (0 != (H % N)) t3++;
  double d4 = t3 * C;
  cout << min(d3, d4) << endl;
  return 0;
}
int main(int argc, char* argv[]) {
  run();
  return 0;
}
