#include <bits/stdc++.h>
using namespace std;
const int N = 1234567;
const int mod = 1e9 + 7;
int main(int argc, char const *argv[]) {
  int hh, m;
  cin >> hh >> m;
  int h, d, c, n;
  cin >> h >> d >> c >> n;
  if (hh >= 20) {
    double answer = ceil((double)h / n) * 0.8 * c;
    cout << setprecision(5) << fixed << answer;
  } else {
    int difference = (20 - hh - 1) * 60 + 60 - m;
    double cost = h + difference * d;
    double answer1 = ceil((double)cost / n) * 0.8 * c;
    double answer2 = ceil((double)h / n) * c;
    if (answer1 < answer2)
      cout << setprecision(5) << fixed << answer1;
    else
      cout << setprecision(5) << fixed << answer2;
  }
  cout << endl;
  return 0;
}
