#include <bits/stdc++.h>
using namespace std;
int main() {
  int hour, minute;
  int hunger_increase, hunger, cost, hunger_decrease;
  cin >> hour;
  cin >> minute;
  cin >> hunger;
  cin >> hunger_increase;
  cin >> cost;
  cin >> hunger_decrease;
  int current_cost;
  int cost_at_20;
  int no_of_buns = ceil((double)hunger / (double)hunger_decrease);
  current_cost = no_of_buns * cost;
  if (hour >= 20) {
    cout << 0.8 * current_cost;
    exit(0);
  }
  int time_to_20 = 60 - minute + 60 * (20 - hour - 1);
  no_of_buns = ceil(double((hunger + time_to_20 * hunger_increase)) /
                    (double)hunger_decrease);
  cost_at_20 = no_of_buns * cost * 0.8;
  if (cost_at_20 < current_cost)
    cout << cost_at_20;
  else
    cout << current_cost;
  return 0;
}
