#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  double hh, mm, h, d, c, n;
  double c1 = 0, c2 = 0;
  cin >> hh >> mm >> h >> d >> c >> n;
  c1 = ceil(h / n);
  c1 = c1 * c;
  if (hh >= 20) {
    c = 0.8 * c;
    c2 = ceil(h / n);
    c2 = c2 * c;
  } else {
    double mins = (20 - (hh + 1)) * 60 + (60 - mm);
    h = h + mins * d;
    c = 0.8 * c;
    c2 = ceil(h / n);
    c2 = c2 * c;
  }
  double ans = min(c1, c2);
  cout << ans;
}
