#include <bits/stdc++.h>
using namespace std;
long long value(long long a, long long b) {
  long long x;
  x = a / b;
  if (a % b != 0) x = x + 1;
  return (x);
}
void solve() {
  long long hh, mm, h, d, c, n;
  cin >> hh >> mm >> h >> d >> c >> n;
  double p, q, l;
  p = value(h, n) * c;
  if ((hh >= 20))
    p = p * 0.8;
  else {
    q = (((20 - hh - 1) * 60 + 60 - mm) * d);
    l = value(h + q, n) * c * 0.8;
    if (l <= p) p = l;
  }
  p = p * 1.0;
  std::cout << std::fixed;
  cout << setprecision(4) << p;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
    cout << "\n";
  }
  return 0;
}
