#include <bits/stdc++.h>
using namespace std;
int main() {
  double H, M, h, d, c, n;
  cin >> H >> M >> h >> d >> c >> n;
  if (H < 20 || H == 20 && M == 0)
    cout << fixed << setprecision(4)
         << min(ceil(h / n) * c,
                ceil((h + ((1200 - ((H * 60) + M)) * d)) / n) * (c * 0.8));
  else {
    cout << fixed << setprecision(4) << ceil(h / n) * (c * 0.8);
  }
  return 0;
}
