#include <bits/stdc++.h>
using namespace std;
void solve() {
  int hh, mm;
  cin >> hh >> mm;
  double H, D, C, N;
  cin >> H >> D >> C >> N;
  if (hh >= 20) {
    C = 4 * C / 5;
    cout << ceil(H / N) * C;
  } else {
    double t = (20 - hh) * 60 - mm;
    double ans1 = ceil(H / N) * C;
    C = 4 * C / 5;
    double ans2 = ceil((H + t * D) / N) * C;
    cout << min(ans1, ans2);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
