#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int hh, mm, i, j, k;
  int H, D, C, N;
  scanf("%d%d", &hh, &mm);
  scanf("%d%d", &H, &D);
  scanf("%d%d", &C, &N);
  int t = hh * 60 + mm;
  int midt = 20 * 60;
  cout << fixed << setprecision(10);
  if (t >= midt) {
    cout << (double)(((H) % (N) == 0 ? ((H) / (N)) : ((H) / (N) + 1)) * C) * .8
         << endl;
  } else
    cout << min((double)(((H) % (N) == 0 ? ((H) / (N)) : ((H) / (N) + 1)) * C),
                (double)((((H + (midt - t) * D)) % (N) == 0
                              ? (((H + (midt - t) * D)) / (N))
                              : (((H + (midt - t) * D)) / (N) + 1)) *
                         C) *
                    .8)
         << endl;
  return 0;
}
