#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm, H, D, C, N;
  cin >> hh >> mm >> H >> D >> C >> N;
  double a1, a2;
  double m = (hh >= 20) ? 0.8 : 1;
  int cnt = 0;
  while (H > cnt * N) cnt++;
  a1 = m * cnt * C;
  cnt = 0;
  int diff = 20 * 60 - (hh * 60 + mm);
  while (H + diff * D > cnt * N) cnt++;
  a2 = 0.8 * cnt * C;
  if (diff < 0)
    printf("%.4f", a1);
  else
    printf("%.4f", min(a1, a2));
  return 0;
}
