#include <bits/stdc++.h>
using namespace std;
const long long array_maxn = 500;
const long long max_maxn = 0x03f03f03f03f;
const long long min_minn = -max_maxn;
int text() {
  cout << "text" << endl;
  return 0;
}
int compute_cost(double& cost, const int& N, const int& C, const int& H) {
  if (H % N) {
    cost = (H / N + 1) * C * (cost);
  } else {
    cost = (H / N) * C * (cost);
  }
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  int hh, mm;
  cin >> hh >> mm;
  int cost_time = 0;
  if (hh < 20) {
    cost_time = (20 - hh - 1) * 60 + (60 - mm);
  }
  int H, D, C, N;
  cin >> H >> D >> C >> N;
  double cost1 = 1;
  compute_cost(cost1, N, C, H);
  H += D * (cost_time);
  double cost2 = 0.8;
  compute_cost(cost2, N, C, H);
  printf("%.4lf\n", min(cost1, cost2));
  return 0;
}
