#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long hh, mm;
  cin >> hh >> mm;
  int H, D, C, N;
  cin >> H >> D >> C >> N;
  int TIME = 20 * 60;
  int NOW = hh * 60 + mm;
  double ans = (H + N - 1) / N * C;
  NOW = min(NOW, TIME);
  ans = min(ans, (double((H + D * (TIME - NOW) + N - 1) / N) * C * 0.8));
  cout << setprecision(6) << fixed << ans;
}
