#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm, h, d, c, n;
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  float a;
  if (h % n == 0)
    a = (h / n) * c;
  else
    a = (h / n + 1) * c;
  float b;
  int tim = hh * 60 + mm;
  if (tim <= 1200) {
    h += (1200 - tim) * d;
    float rate = (float)c * 4 / 5;
    if (h % n == 0) {
      b = (h / n) * rate;
    } else
      b = (h / n + 1) * rate;
  } else {
    float rate = (float)c * 4 / 5;
    if (h % n == 0)
      b = (h / n) * rate;
    else
      b = (h / n + 1) * rate;
  }
  cout << fixed << setprecision(4) << min(a, b);
  return 0;
}
