#include <bits/stdc++.h>
using namespace std;
int main() {
  float cost, c1, c2;
  int hh, mm, H, delta, P, pwr;
  int timeDelta;
  int finalH;
  cin >> hh >> mm;
  cin >> H >> delta >> P >> pwr;
  cout << fixed << setprecision(4);
  int neededBun, neededBun1;
  if (hh >= 20) {
    if (H % pwr) {
      neededBun = H / pwr + 1;
    } else {
      neededBun = H / pwr;
    }
    cost = neededBun * (P * 0.8);
  } else {
    timeDelta = (20 - hh) * 60 - mm;
    finalH = H + delta * timeDelta;
    if (finalH % pwr) {
      neededBun1 = finalH / pwr + 1;
    } else {
      neededBun1 = finalH / pwr;
    }
    c1 = neededBun1 * (P * 0.8);
    if (H % pwr) {
      neededBun = H / pwr + 1;
    } else {
      neededBun = H / pwr;
    }
    c2 = neededBun * P;
    if (c1 < c2)
      cost = c1;
    else
      cost = c2;
  }
  cout << cost << endl;
  return 0;
}
