#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long h, m;
  cin >> h >> m;
  long long H, D, N, C;
  cin >> H >> D >> C >> N;
  float mn = LLONG_MAX;
  for (long long i = h; i < 24; i++) {
    if (i == h) {
      for (long long j = m; j <= 59; j++) {
        long long rem = (H / N);
        if (H % N) {
          rem++;
        }
        float cost = C;
        if (i >= 20) {
          cost = (float)((float)cost * (80.00) / (float)(100.00));
        }
        float nw_cost = (float)(rem * cost);
        mn = min(mn, nw_cost);
        H += D;
      }
      continue;
    }
    for (long long j = 0; j <= 59; j++) {
      long long rem = (H / N);
      if (H % N) {
        rem++;
      }
      float cost = C;
      if (i >= 20) {
        cost = (float)((float)cost * (80.00) / (float)100.00);
      }
      float nw_cost = (float)(rem * cost);
      mn = min(mn, nw_cost);
      H += D;
    }
  }
  printf("%.4f", mn);
  return 0;
}
