#include <bits/stdc++.h>
using namespace std;
const int N = 1100001;
const int M = 6666666;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-7;
int main() {
  int h, m;
  scanf("%d%d", &h, &m);
  int H, D, C, N;
  scanf("%d%d%d%d", &H, &D, &C, &N);
  if (h >= 20) {
    printf("%.4lf\n", 0.8 * (H / N + (H % N != 0)) * C);
  } else {
    int tmp = (((20 - h - 1) * 60 + 60 - m) * D + H);
    double ans2 = (tmp / N + (tmp % N != 0)) * (0.8) * C;
    double ans1 = (H / N + (H % N != 0)) * C;
    printf("%.4lf\n", min(ans1, ans2));
  }
  return 0;
}
