#include <bits/stdc++.h>
using namespace std;
int main() {
  long long hh, mm;
  cin >> hh >> mm;
  long long time = hh * 60 + mm;
  long long h, d, c, n;
  cin >> h >> d >> c >> n;
  long double ans = 1e9;
  if (time >= 20 * 60) {
    long long cnt = h / n;
    if (h % n != 0) {
      cnt++;
    }
    ans = (long double)cnt * 0.8 * c;
    cout.precision(5);
    cout << ans;
    return 0;
  }
  long long cnt = h / n;
  if (h % n != 0) {
    cnt++;
  }
  ans = (long double)cnt * c;
  long long temp = h + (20 * 60 - time) * d;
  cnt = temp / n;
  if (temp % n != 0) {
    cnt++;
  }
  ans = min(ans, (long double)cnt * 0.8 * c);
  cout.precision(5);
  cout << ans;
  return 0;
}
