#include <bits/stdc++.h>
using namespace std;
int hh, mm, h, d, c, n;
int cnt1, cnt2, m1, h1, t;
int main() {
  double sum1, sum2;
  sum1 = sum2 = 99999999;
  scanf("%d %d %d %d %d %d", &hh, &mm, &h, &d, &c, &n);
  if (hh < 20) {
    if (h % n)
      cnt1 = h / n + 1;
    else
      cnt1 = h / n;
    sum1 = cnt1 * c;
    if (0 >= mm)
      m1 = 0 - mm;
    else {
      m1 = 60 - mm;
      hh = hh + 1;
    }
    t = m1 + (20 - hh) * 60;
    h1 = h + t * d;
    if (h1 % n)
      cnt2 = h1 / n + 1;
    else
      cnt2 = h1 / n;
    sum2 = cnt2 * c * 0.8;
  } else {
    if (h % n)
      cnt1 = h / n + 1;
    else
      cnt1 = h / n;
    sum1 = cnt1 * c * 0.8;
  }
  double sum = min(sum1, sum2);
  printf("%.4lf\n", sum);
}
