#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
double h, d, c, n, mx;
int hh, mm;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> hh >> mm;
  hh = hh * 60 + mm;
  cin >> h >> d >> c >> n;
  double nec = ceil(h / n) * c;
  if (hh >= 1200 && hh < 1440)
    return cout << setprecision(5) << fixed << nec * 0.8, 0;
  mm = 20 * 60;
  int diff = mm - hh;
  double nec2 = ceil((diff * d + h) / n) * c;
  cout << setprecision(5) << fixed << min(nec2 * 0.8, nec);
  return 0;
}
