#include <bits/stdc++.h>
using namespace std;
float calc(int h, int d, int c, int n) {
  float a;
  if (h % n == 0) {
    a = (h / n) * c;
  } else
    a = ((h / n) + 1) * c;
  return a;
}
int main() {
  int p = 0, q = 0;
  int h, d, c, n, eh;
  int hh, mm;
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  float a = calc(h, d, c, n);
  if (hh >= 20) {
    a = a * 0.8;
    printf("%f", a);
    return 0;
  }
  if (mm != 00) {
    q = 60 - mm;
    p = 19 - hh;
  } else
    p = 20 - hh;
  eh = (p * 60 + q) * d;
  h = h + eh;
  float b = calc(h, d, c, n);
  b = b * 0.8;
  if (b < a) a = b;
  printf("%f", a);
  return 0;
}
