#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 20;
const long long INF = 1e18 + 1;
const int MOD = 1e9 + 7;
void startSetting() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
int main() {
  startSetting();
  string s1, s2;
  int th, tm;
  long double h, d, c, n;
  cin >> s1 >> s2;
  stringstream ss;
  ss << s1;
  ss >> th;
  ss.clear();
  ss << s2;
  ss >> tm;
  ss.clear();
  cin >> h >> d >> c >> n;
  int to20 = 60 * (19 - th) + (60 - tm);
  long double ans = 0;
  if (to20 <= 0) {
    to20 = 0;
    ans = 0.8 * (long double)c * (ceil((h + d * to20) / n));
  } else {
    ans = min(0.8 * (long double)c * (ceil((h + d * to20) / n)),
              (long double)c * (ceil(h / n)));
  }
  cout << setprecision(100) << ans;
  return 0;
}
