#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int iMAX = INT_MAX;
const int iMIN = -INT_MAX;
int main(void) {
  long double h, m;
  cin >> h >> m;
  long double H, D, C, N;
  cin >> H >> D >> C >> N;
  if (h < 20)
    printf("%0.8Lf",
           min(ceil(H / N) * C, ceil((H + (1200.0 - (h * 60.0 + m)) * D) / N) *
                                    (8.0 * C / 10.0)));
  else
    printf("%0.8Lf", ceil(H / N) * (8 * C / 10.0));
  return 0;
}
