#include <bits/stdc++.h>
using namespace std;
bool check(int a, int b) { return a == b; }
int main() {
  int hh, mm;
  cin >> hh >> mm;
  int h, d, c, n;
  cin >> h >> d >> c >> n;
  if (hh >= 20) {
    if (h % n == 0)
      printf("%.4f\n", (h / n) * ((float)4 * c) / 5);
    else
      printf("%.4f\n", (h / n + 1) * ((float)4 * c) / 5);
  } else {
    int f = 60 - mm + 60 * (20 - hh - 1);
    int total = h + d * f;
    float val1, val2;
    if (total % n == 0)
      val1 = (total / n) * ((float)4 * c) / 5;
    else
      val1 = (total / n + 1) * ((float)4 * c) / 5;
    if (h % n == 0)
      val2 = c * (h / n);
    else
      val2 = c * (h / n + 1);
    printf("%.4f\n", min(val1, val2));
  }
  return 0;
}
