#include <bits/stdc++.h>
using namespace std;
int main() {
  double hh, m, d, c, h, n, res1, res2, b;
  int cnt, cnt2;
  cin >> hh >> m >> h >> d >> c >> n;
  if ((int)h % (int)n != 0)
    cnt = (int)h / n + 1;
  else
    cnt = (int)h / n;
  res1 = cnt * c;
  int time = hh * 60 + m;
  int dif;
  if (time < 1200) h += (1200 - time) * d;
  if ((int)h % (int)n != 0)
    cnt2 = h / n + 1;
  else
    cnt2 = h / n;
  res2 = cnt2 * c * 0.8;
  printf("%.2lf", min(res1, res2));
  return 0;
}
