#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm, h, d, c, n;
  double cast1, cast2;
  cin >> hh >> mm >> h >> d >> c >> n;
  if (hh < 20) {
    cast1 = (h / n) * c;
    if (h % n != 0) {
      cast1 += c;
    }
    cast2 = (((20 * 60 - hh * 60 - mm) * d + h) / n) * c * 0.8;
    if (((20 * 60 - hh * 60 - mm) * d + h) % n != 0) {
      cast2 += 0.8 * c;
    }
    printf("%.4f", min(cast1, cast2));
  } else {
    cast1 = (h / n) * 0.8 * c;
    if (h % n != 0) {
      cast1 += 0.8 * c;
    }
    printf("%.4f", cast1);
  }
}
