#include <bits/stdc++.h>
using namespace std;
int h, m, H, D, C, N;
void cambiaHora() {
  if (m) {
    H += (D * (60 - m));
    m = 0;
    h++;
  }
  if (h < 20) H += (D * (60 * (20 - h)));
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> h >> m;
  cin >> H >> D >> C >> N;
  if (h >= 20) {
    int necesito = ceil((double)H / (double)N);
    double ans = (double)necesito * (double)C * (double)0.8;
    cout << fixed << setprecision(10) << ans << "\n";
  } else {
    int necesito = ceil((double)H / (double)N);
    double ans = (double)necesito * (double)C;
    cambiaHora();
    necesito = ceil((double)H / (double)N);
    double ans2 = (double)necesito * (double)C * (double)0.8;
    ans = min(ans, ans2);
    cout << fixed << setprecision(10) << ans << "\n";
  }
  return 0;
}
