#include <bits/stdc++.h>
using namespace std;
int hour, minute, h, d, n;
double c;
int wakeUpTime, discountTime = 20 * 60;
int main() {
  cin >> hour >> minute >> h >> d >> c >> n;
  wakeUpTime = hour * 60 + minute;
  int remainTime = discountTime - wakeUpTime;
  double discountPrice = c - ((double)(c * 20) / 100);
  if (remainTime <= 0) {
    c = discountPrice;
    cout << (double)(ceil((double)h / n)) * c;
  } else {
    cout << (double)min((ceil((double)h / n)) * c,
                        ceil(((double)remainTime * d + h) / n) * discountPrice);
  }
  return 0;
}
