#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long double h, d, n, hf = 0, mf = 0, hh, mm, timeleft = 0;
  long double c, c2 = 0, c1 = 0, ans = 0;
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  if (hh < 20) {
    if (mm > 0) {
      hf = 19 - hh;
      mf = 60 - mm;
    } else {
      hf = 20 - hh;
    }
    timeleft = (hf * 60) + mf;
    c1 = ceil(h / n);
    c1 *= c;
    h += (timeleft * d);
    c2 = ceil(h / n);
    c2 = c2 * c * 0.8;
  } else {
    hf = 23 - hh;
    mf = 59 - mm;
    c1 = ceil(h / n);
    c1 = c1 * c * 0.8;
    timeleft = (hf * 60) + mf + 20;
    h += (timeleft * d);
    c2 = ceil(h / n);
    c2 = c2 * c * 0.8;
  }
  ans = min(c1, c2);
  cout << setprecision(4) << fixed << ans << '\n';
}
