#include <bits/stdc++.h>
using namespace std;
int hh, mm, d, h, n;
double c;
double Calculate() {
  int buns_needed = ceil((double)h / n);
  double cost = buns_needed * c;
  return cost;
}
void solve() {
  cin >> hh >> mm >> h >> d >> c >> n;
  if (hh >= 20) {
    c -= ((double)(20 / 100.0) * c);
    cout << fixed << setprecision(4) << Calculate() << "\n";
  } else {
    double res1 = Calculate();
    int x = (60 - mm) + ((20 - (hh + 1)) * 60);
    h += (x * d);
    c -= ((double)(20 / 100.0) * c);
    double res2 = Calculate();
    cout << fixed << setprecision(4) << min(res1, res2) << "\n";
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  solve();
  return 0;
}
