#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5 + 10;
const double eps = 1e-9;
const int inf = 1e9;
int a[mx];
int main() {
  double h, m, H, D, C, N;
  cin >> h >> m >> H >> D >> C >> N;
  int z1 = h * 60 + m;
  int z2 = 20 * 60;
  int dif = max(0, z2 - z1);
  double HH = (dif * D) + H;
  double cc = C - (C * 2) / 10;
  int x1 = (H + N - 1) / N;
  int x2 = (HH + N - 1) / N;
  double tmp1 = x1 * C;
  double tmp2 = x2 * cc;
  double tmp = min(tmp1, tmp2);
  cout << fixed << setprecision(6) << tmp << endl;
}
