#include <bits/stdc++.h>
float min(float a, float b) { return (a < b) ? a : b; }
int main() {
  int h, m;
  scanf("%d%d", &h, &m);
  int hu, d, c, n, h1, h2, s1;
  float s2;
  scanf("%d%d%d%d", &hu, &d, &c, &n);
  h1 = hu;
  if (h1 % n == 0)
    h1 /= n;
  else
    h1 = h1 / n + 1;
  if (h < 20) {
    m = (60 - m) * d + (20 - h - 1) * 60 * d;
    h2 = hu + m;
    if (h2 % n == 0)
      h2 /= n;
    else
      h2 = h2 / n + 1;
    s1 = h1 * c;
    s2 = h2 * c * 0.8;
    printf("%.4f\n", min(s1, s2));
  } else {
    s2 = h1 * c * 0.8;
    printf("%.4f\n", s2);
  }
  return 0;
}
