#include <bits/stdc++.h>
using namespace std;
int hh, mm, H, D, C, N;
double sum;
int getMinutes() { return (20 - hh) * 60 - mm; }
int main() {
  scanf("%d %d %d %d %d %d", &hh, &mm, &H, &D, &C, &N);
  if (hh >= 20)
    sum = (H / N + (H % N ? 1 : 0)) * C * 0.8;
  else
    sum = min(
        (H / N + (H % N ? 1 : 0)) * C * 1.0,
        ((getMinutes() * D + H) / N + ((getMinutes() * D + H) % N ? 1 : 0)) *
            C * 0.8);
  printf("%.4lf\n", sum);
  return 0;
}
