#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  double hh, mm, h, d, c, n, x, s1, s2;
  cin >> hh >> mm >> h >> d >> c >> n;
  x = max(0.0, 20.0 * 60.0 - hh * 60.0 - mm);
  x *= d;
  s1 = ceil(h / n) * c;
  s2 = 0.8 * (ceil((h + x) / n) * c);
  cout << fixed << setprecision(4) << min(s1, s2);
  return 0;
}
