#include <bits/stdc++.h>
using namespace std;
int prime(int n) {
  int i;
  if (n == 2) return 1;
  if (n % 2 == 0) return 0;
  int root = sqrt(n);
  for (i = 3; i <= root; i = i + 2) {
    if (n % i == 0) return 0;
  }
  return 1;
}
int main() {
  int h, m, H, D, C, N, t;
  cin >> h >> m >> H >> D >> C >> N;
  if (h < 20)
    t = (60 - m) + (20 - h - 1) * 60;
  else
    t = 0;
  int x = t * D + H;
  double discount = C - (C * 20) / 100.0;
  int n = (x + (N - 1)) / N;
  double cost = discount * n;
  double c = ((H + (N - 1)) / N) * C;
  if (cost >= c)
    printf("%llf\n", c);
  else
    printf("%llf\n", cost);
}
