#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int hour, minute;
  cin >> hour >> minute;
  float h, d, n, c;
  cin >> h >> d >> c >> n;
  float x = 0;
  if (hour < 20) {
    x = (20 - 1 - hour) * 60 + (60 - minute);
  }
  float tt = ceil(h / n);
  cout << (tt * c < ceil(((x * d) + h) / n) * c * .8
               ? tt * c
               : ceil(((x * d) + h) / n) * c * .8);
  return 0;
}
