#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
template <class T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline T min(T a, T b, T c, T d) {
  return min(min(a, b), min(c, d));
}
template <class T>
inline T max(T a, T b, T c, T d) {
  return max(max(a, b), max(c, d));
}
const int maxn = 100005;
const int N = 1000005;
double hh, mm;
int h, c;
int n, d;
int t;
double ans;
int main() {
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  if (hh < 20) {
    t = (20 - hh) * 60 - mm;
    if ((h + t * d) % n)
      t = (h + t * d) / n + 1;
    else
      t = (h + t * d) / n;
    ans = double(t * 0.8 * c);
    if (h % n)
      t = h / n + 1;
    else
      t = h / n;
    ans = min(ans, double(t * c));
  } else {
    if (h % n)
      t = h / n + 1;
    else
      t = h / n;
    ans = double(t * c * 0.8);
  }
  printf("%.4f", ans);
  return 0;
}
