#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm;
  cin >> hh >> mm;
  int h, d, c, n;
  cin >> h >> d >> c >> n;
  double cost = 0.0;
  int t_buns;
  if (hh >= 20) {
    t_buns = ceil((double)h / (double)n);
    cost = t_buns * c;
    double dis = cost * 0.2;
    cost = cost - dis;
  } else {
    t_buns = ceil((double)h / (double)n);
    cost = t_buns * c;
    int minutes = (hh * 60) + mm;
    minutes = 1200 - minutes;
    h = h + (minutes * d);
    int t_buns1 = ceil((double)h / (double)n);
    double cost1 = t_buns1 * c;
    double dis = cost1 * 0.2;
    cost1 = cost1 - dis;
    if (cost1 < cost) {
      cost = cost1;
    }
  }
  printf("%.3f", cost);
  return 0;
}
