#include <bits/stdc++.h>
using namespace std;
int main() {
  int buns, mins = 0, hh, mm, h, d, c, n;
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  if (hh < 20) {
    mm = 60 - mm;
    mins = (19 - hh) * 60 + mm;
  }
  int hunger = h + mins * d;
  double cost1 = 0, cost2 = 0;
  buns = h / n;
  if (h % n != 0) {
    buns++;
  }
  cost1 = buns * c;
  if (h == hunger) {
    if (hh >= 20) {
      cost1 *= (0.8);
    }
    printf("%.4lf\n", cost1);
  } else {
    buns = hunger / n;
    if (hunger % n != 0) {
      buns++;
    }
    cost2 = buns * (c * (0.8));
    if (cost1 > cost2) {
      printf("%.4lf\n", cost2);
    } else {
      printf("%.4lf\n", cost1);
    }
  }
}
