#include <bits/stdc++.h>
using namespace std;
int hh, mm;
int h, h2, d, c, n;
float c80, p1, p2;
int main() {
  cin >> hh >> mm >> h >> d >> c >> n;
  c80 = 0.8 * (double)c;
  if (hh >= 20) {
    if (h % n == 0) {
      cout << c80 * (h / n);
    } else {
      cout << c80 * ((h / n) + 1);
    }
    return 0;
  }
  h2 = h + (d * ((60 - mm) + (60 * (19 - hh))));
  if (h % n == 0) {
    p1 = c * (h / n);
  } else {
    p1 = c * ((h / n) + 1);
  }
  if (h2 % n == 0) {
    p2 = c80 * (h2 / n);
  } else {
    p2 = c80 * ((h2 / n) + 1);
  }
  if (p1 > p2) {
    cout << p2;
  } else {
    cout << p1;
  }
}
