#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm;
  float H, D, C, N, ans, a1, a2;
  cin >> hh >> mm;
  cin >> H >> D >> C >> N;
  if (hh >= 20 && hh <= 23 && mm >= 0 && mm <= 59)
    ans = ceil(H / N) * 0.8 * C;
  else {
    int mins = (20 - hh - 1) * 60 + (60 - mm);
    a1 = ceil((H + mins * D) / N) * 0.8 * C;
    a2 = ceil(H / N) * C;
    if (a1 < a2)
      ans = a1;
    else
      ans = a2;
  }
  printf("%.4f\n", ans);
  return 0;
}
