#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm;
  cin >> hh >> mm;
  int H, D, C, N;
  cin >> H >> D >> C >> N;
  if (hh >= 20 and mm >= 0) {
    double x = (20 * C) * 1. / 100;
    double need1 = ceil(H * 1. / N);
    double ans2 = need1 * (C - x);
    printf("%.4f", ans2);
    return 0;
  } else {
    double need = ceil(H * 1. / N);
    double ans1 = need * C;
    int ikk = 60 - mm;
    int jami = 0;
    if (ikk == 60) {
      hh++;
      jami += 60;
      ikk = 0;
    } else {
      jami += ikk;
      hh++;
      ikk = 0;
    }
    jami += (20 - hh) * 60;
    H += jami * D;
    double need1 = ceil(H * 1. / N);
    double x = (20 * C) * 1. / 100;
    double ans2 = need1 * (C - x);
    printf("%.4f", min(ans1, ans2));
  }
}
