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