#include <bits/stdc++.h>
using namespace std;
int main() {
  float h, d, c, n, bhp, e, de;
  int hh, mm, bhh{19}, bmm{60};
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  bhp = h;
  if (hh <= bhh) bhp = h + ((bhh - hh) * 60 + bmm - mm) * d;
  de = ceil(bhp / n) * c * 0.8;
  e = ceil(h / n) * c;
  cout << setprecision(4) << fixed << (de <= e ? de : e);
}
