#include <bits/stdc++.h>
using namespace std;
int hh, mm, h, d, c, n;
char str[3], str1[3];
int main() {
  cin >> str >> str1 >> h >> d >> c >> n;
  hh = (str[0] - '0') * 10 + str[1] - '0';
  mm = (str1[0] - '0') * 10 + str1[1] - '0';
  int cnt = 0;
  double min1, min2;
  if (hh < 20) {
    cnt += (20 - hh) * 60;
    if (mm) {
      cnt -= 60;
      cnt += 60 - mm;
    }
  }
  int H = h + cnt * d;
  int bag = H / n;
  if (H % n) {
    bag++;
  }
  min1 = (double)bag * ((double(c) * 0.8));
  int bag1 = h / n;
  if (h % n) {
    bag1++;
  }
  min2 = (double)bag1 * (double(c));
  printf("%.4lf\n", min(min1, min2));
}
