#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm, t, t1;
  double H, D, C, N;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> hh >> mm >> H >> D >> C >> N;
  double ans1, ans2;
  t = 20 * 60;
  t1 = hh * 60 + mm;
  int cnt;
  if (t1 >= t) {
    cnt = (H + N - 1) / N;
    ans1 = 1.0 * cnt * C * 0.8;
    printf("%.5f\n", ans1);
  } else {
    cnt = (H + N - 1) / N;
    ans1 = 1.0 * cnt * C;
    H += (t - t1) * D;
    cnt = (H + N - 1) / N;
    ans2 = 1.0 * cnt * C * 0.8;
    printf("%.5f\n", min(ans1, ans2));
  }
  return 0;
}
