#include <bits/stdc++.h>
using namespace std;
template <class type>
struct mycomp {
  bool operator()(const type& first, const type& second) const {
    return first < second;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int h, m;
  double H, D, C, N;
  cin >> h >> m >> H >> D >> C >> N;
  int delta = 1200 - h * 60 - m;
  cout.precision(4);
  cout << fixed
       << min(ceil(H / N) * C, ceil((H + D * max(delta, 0)) / N) * C * 0.8);
}
