#include <bits/stdc++.h>
using namespace std;
const int maxn = 0;
int n, hh, mm, hunger, inc, cost, decr;
int main() {
  cin >> hh >> mm;
  cin >> hunger >> inc >> cost >> decr;
  double one = 0.0, two = 0.0;
  if (hh < 20) {
    int buy = ceil((double)hunger / (double)decr);
    one = buy * cost;
    double newcost = cost * 0.8;
    double t = 1200 - (hh * 60 + mm);
    double newhunger = hunger + (t * inc);
    buy = ceil((double)newhunger / (double)decr);
    two = buy * newcost;
    printf("%.4lf", min(one, two));
  } else {
    double newcost = cost * 0.8;
    int buy = ceil((double)hunger / (double)decr);
    one = buy * newcost;
    printf("%.4lf", one);
  }
}
