#include <bits/stdc++.h>
using namespace std;
float hh, mm, h, d, c, n, tt, m;
float badian = 1200;
float calcost(float hun, float co) {
  float ret;
  if ((int)hun % (int)n == 0) {
    if (hun >= n)
      ret = (int)(hun / n) * co;
    else
      ret = co;
  } else {
    if (hun >= n)
      ret = (int)(hun / n + 1) * co;
    else
      ret = co;
  }
  return ret;
}
int main() {
  scanf("%f%f%f%f%f%f", &hh, &mm, &h, &d, &c, &n);
  tt = hh * 60 + mm;
  m = calcost(h, c);
  m = min(m, calcost(h + ((badian - tt) * d), c * 0.8));
  for (int i = 1; i * n < h + ((badian - tt) * d); i++) {
    m = min(m, i * c + calcost(h + (d * (badian - tt)) - (i * n), c * 0.8));
  }
  if (tt >= badian) m = calcost(h, c * 0.8);
  printf("%f", m);
  return 0;
}
