#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm, h, d, c, n;
  scanf("%d%d%d%d%d%d", &hh, &mm, &h, &d, &c, &n);
  double a, b;
  int t;
  if (hh < 20) {
    a = ceil(h / (double)n) * c;
    if (mm == 0)
      t = (20 - hh) * 60 + mm;
    else
      t = (20 - hh - 1) * 60 + (60 - mm);
    b = ceil((h + t * d) / (double)n) * (c * 0.8);
  } else {
    t = 0;
    a = b = ceil((h + t * d) / (double)n) * (c * 0.8);
  }
  if (a > b)
    printf("%.4lf\n", b);
  else
    printf("%.4lf\n", a);
  return 0;
}
