#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
const double eps = 1e-8;
const long long MAX = 1e7 + 20;
template <class T>
T gcd(T a, T b) {
  return (b != 0 ? gcd<T>(b, a % b) : a);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd<T>(a, b) * b);
}
inline const int EQ(double tmp) {
  if (fabs(tmp) < eps) return 0;
  return tmp > eps ? 1 : -1;
}
long long BM(long long B, long long P, long long M) {
  long long R = 1;
  while (P > 0) {
    if (P & 1) {
      R = (R * B) % M;
    }
    P /= 2;
    B = (B * B) % M;
  }
  return (long long)R;
}
long long MI(long long x, long long m) { return BM(x, m - 2, m); }
int main() {
  int hh, m;
  cin >> hh >> m;
  int h, d, c, n;
  cin >> h >> d >> c >> n;
  double need = (h / n);
  if (h % n != 0) need++;
  need *= c;
  int x = 20 - hh - 1, y = 60 - m;
  if (hh >= 20) {
  }
  int tm = (x * 60) + y;
  tm *= d;
  tm += h;
  if (hh >= 20) {
    tm = h;
  }
  double need1 = tm / n;
  if (tm % n != 0) need1++;
  need1 *= c;
  need1 = need1 - (double(20 * need1) / 100);
  cout << min(need, need1) << "\n";
  return 0;
}
