#include <bits/stdc++.h>
using namespace std;
using ii = pair<long long, long long>;
void solve() {
  long long x, y, h, d, c, n;
  double cost, c1, c2;
  cin >> x >> y >> h >> d >> c >> n;
  if (x >= 20) {
    cost = ceil(h / (double)n) * c;
    cost *= 0.8;
  } else {
    c1 = ceil(h / (double)n) * c;
    h += (abs(20 - x) * 60 - y) * d;
    c2 = ceil(h / (double)n) * c;
    c2 *= 0.8;
    cost = min(c1, c2);
  }
  cout << fixed << setprecision(3) << cost << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
