#include <bits/stdc++.h>
int main() {
  short hour, min;
  std::cin >> hour >> min;
  long h;
  int d, c, n;
  double cost;
  std::cin >> h >> d >> c >> n;
  if (h > 0) {
    if (hour < 20) {
      if (ceil(double(h) / double(n)) * double(c) <
          ceil((h + d * (double(20 - hour - 1) * 60 + double(60 - min))) /
               double(n)) *
              double(c) * 0.8) {
        cost = ceil(double(h) / double(n)) * double(c);
      } else {
        cost = ceil((h + d * (double(20 - hour - 1) * 60 + double(60 - min))) /
                    double(n)) *
               double(c) * 0.8;
      }
    } else {
      cost = double(c) * 0.8 * ceil(double(h) / double(n));
    }
  } else {
    cost = 0;
  }
  printf("%.4f", cost);
}
