#include <bits/stdc++.h>
using namespace std;
vector<int> adj[10000];
queue<int> q;
int level[10000];
void BFS(int source) {
  int i, j, k, u, v;
  for (i = 0; i < 10000; i++) {
    level[i] = -1;
  }
  q.push(source);
  level[source] = 0;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (i = 0; i < adj[u].size(); i++) {
      v = adj[u][i];
      if (level[v] == -1) {
        level[v] = abs(level[u] - 1);
        q.push(v);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int i, j, k, l, x, y, n, f = 0, t;
  int hh, mm, minit;
  double H, D, C, N;
  cin >> hh >> mm;
  cin >> H >> D >> C >> N;
  minit = hh * 60 + mm;
  if (hh >= 0 && hh < 20) {
    if (C * ceil(H / N) >
        (C - C * .2) * ceil((H + (20 * 60 - minit) * D) / N)) {
      cout << fixed << setprecision(6)
           << (C - C * .2) * ceil((H + (20 * 60 - minit) * D) / N);
      return 0;
    } else {
      cout << C * ceil(H / N);
    }
  } else {
    C = C - C * 0.2;
    cout << fixed << setprecision(6) << C * ceil(H / N);
  }
}
