#include <bits/stdc++.h>
using namespace std;
int main() {
  long long hh, mm, h, d, c, n, y, z, m, p;
  cin >> hh >> mm;
  cin >> h >> d >> c >> n;
  double x = 0, q, s, r, t;
  t = h % n;
  if (t == 0)
    q = h / n;
  else
    q = h / n + 1;
  if (hh >= 20) {
    x = (q * c) - (q * c * .2);
  } else {
    r = q * c;
    y = 20 - hh;
    z = (y - 1) * 60 + (60 - mm);
    m = z * d + h;
    if (m % n == 0)
      q = m / n;
    else
      q = m / n + 1;
    s = (q * c) - (q * c * .2);
    s = ceil(s);
    x = min(r, s);
  }
  cout << x;
}
