#include <bits/stdc++.h>
using namespace std;
int main() {
  int hh, mm, H, D, C, N;
  cin >> hh >> mm >> H >> D >> C >> N;
  double ManyNow, ManyAfter, MoneyNow, MoneyAfter, NeedMoney;
  if (hh < 20) {
    ManyNow = H / N;
    if (H % N != 0) ManyNow += 1;
    MoneyNow = ManyNow * C;
    int Minutes = 20 * 60 - (hh * 60 + mm);
    H += Minutes * D;
    ManyAfter = H / N;
    if (H % N != 0) ManyAfter += 1;
    MoneyAfter = (((ManyAfter * C) / 100) * 80);
    NeedMoney = min(MoneyNow, MoneyAfter);
    printf("%.4lf\n", NeedMoney);
  }
  if (hh >= 20) {
    ManyNow = H / N;
    if (H % N != 0) ManyNow += 1;
    NeedMoney = ManyNow * C * 0.8;
    printf("%.4lf\n", NeedMoney);
  }
  return 0;
}
