#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, k, x, y, z, t;
  long long hh, mm, h, d, c, N;
  cin >> hh >> mm;
  cin >> h >> d >> c >> N;
  if (hh >= 20) {
    double cc = 0.8 * c;
    k = (h + N - 1) / N;
    double ans = 1.0 * k * cc;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
  }
  double ans1, ans2;
  k = (h + N - 1) / N;
  ans1 = 1.0 * k * c;
  x = (60 - mm) + (20 - hh - 1) * 60;
  h += x * d;
  double cc = 0.8 * c;
  k = (h + N - 1) / N;
  ans2 = 1.0 * k * cc;
  cout << fixed << setprecision(10) << min(ans1, ans2) << endl;
}
