#include <bits/stdc++.h>
using namespace std;
int func(string s) { return (s[1] - '0') + 10 * (s[0] - '0'); }
int main() {
  ios::sync_with_stdio(false);
  string s1, s2;
  cin >> s1 >> s2;
  int hh, mm;
  hh = func(s1);
  mm = func(s2);
  int h, d, c, n;
  cin >> h >> d >> c >> n;
  if (hh >= 20) {
    printf("%0.08lf\n", ceil(h / (n * 1.0)) * c * 0.8);
    return 0;
  }
  int x = 60 * (20 - hh - 1) + 60 - mm;
  double y = ceil(h / (n * 1.0)) * c;
  double z = ceil((h + x * d) / (n * 1.0)) * c * 0.8;
  printf("%0.08lf\n", min(z, y));
  return 0;
}
