#include <bits/stdc++.h>
using namespace std;
const long long a = 1e9 + 7;
long long power(long long n, long long m, long long p) {
  int res = 1;
  while (m > 0) {
    if (n & 1) {
      res = (res * n) % p;
    }
    n = (n * n) % p;
    m >>= 1;
  }
  return res % p;
}
bool prime(long long b) {
  for (long long i = 2; i <= sqrt(b); i++) {
    if (b % i == 0) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long h, mini, tmin;
    cin >> h >> mini;
    long double hu, d, c, n, a, b, maxi;
    cin >> hu >> d >> c >> n;
    cout.precision(6);
    if (h < 20) {
      tmin = (20 - h) * 60 - mini;
      a = ceil(hu / n) * c;
      b = (ceil((hu + tmin * d) / n) * (4 * c)) / 5;
      maxi = min(a, b);
    } else {
      maxi = (ceil(hu / n) * (4 * c)) / 5;
    }
    cout << maxi << "\n";
  }
  return 0;
}
