#include <bits/stdc++.h>
using namespace std;
int getremaining(int h, int m) {
  int res = 0;
  for (int i = 0; i < INT_MAX; i++) {
    if (h >= 20) break;
    if (m == 59) {
      h++, m = 0;
      h %= 24, res++;
      continue;
    }
    m++;
    res++;
  }
  return res;
}
int main() {
  int ht, mt;
  cin >> ht >> mt;
  int remaining = getremaining(ht, mt);
  int h, d, c, n;
  cin >> h >> d >> c >> n;
  int needed_now = ((h / n) + ((h % n) != 0));
  double cost_now = needed_now * c;
  int needed_later =
      (((h + remaining * d) / n) + (((h + remaining * d) % n) != 0));
  double cost_later = needed_later * (c * 0.8);
  printf("%.4f\n", min(cost_now, cost_later));
  return 0;
}
