#include <bits/stdc++.h>
int main() {
  int hh, mm, h, d, c, n, minute, hung, bun;
  float tk, distk, bundis, tkdis;
  scanf("%d%d", &hh, &mm);
  scanf("%d%d%d%d", &h, &d, &c, &n);
  if (hh >= 20) {
    bun = h / n;
    if (bun * n != h) {
      bun++;
    }
    tk = bun * c;
    distk = 0.8 * tk;
    printf("%.04lf\n", distk);
  } else if (hh < 20) {
    bun = h / n;
    if (bun * n != h) {
      bun++;
    }
    tk = bun * c;
    minute = ((20 - hh) * 60) - mm;
    hung = (minute * d) + h;
    bundis = hung / n;
    if (bundis * n != hung) {
      bundis++;
    }
    tkdis = bundis * c;
    distk = 0.8 * tkdis;
    if (distk > tk)
      printf("%.04lf\n", tk);
    else
      printf("%.04lf\n", distk);
  }
  return 0;
}
