#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool fs(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
double fun(int h, double c, int n) {
  double ans;
  if (h % n == 0)
    ans = h / n;
  else
    ans = h / n + 1;
  return ans * c;
}
int main() {
  int h, n;
  double a, b, d, c;
  double res = 20 / 100, x, y;
  cin >> a >> b;
  cin >> h >> d >> c >> n;
  a = a * 60 + b;
  b = 20 * 60 - a;
  if (a >= 1200)
    cout << fun(h, c - c * 20 / 100, n) << endl;
  else
    cout << min(fun(h + b * d, c - c * 20 / 100, n), fun(h, c, n)) << endl;
  return 0;
}
