#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double eps = 1e-9;
long double pi = 3.14159265358979323846264338327950;
long double e = 2.7182818284590452353602874713527;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  double h, m, H, D, C, N;
  double amount, cost1, cost2, cost3;
  cin >> h >> m >> H >> D >> C >> N;
  if (h >= 20 && h <= 23) {
    amount = ceil(H / N);
    cost1 = amount * 0.8 * C;
    cout << fixed << setprecision(6) << cost1 << endl;
  } else {
    double rest = (20 - h);
    int c = (((rest * 60) - m) * D) + H;
    amount = ceil(c / N);
    cost2 = amount * C * 0.8;
    cost3 = ceil(H / N) * C;
    cout << fixed << setprecision(6) << min(cost2, cost3) << endl;
  }
  return 0;
}
