#include <bits/stdc++.h>
using namespace std;
const int Max = 1e7 + 100;
int main() {
  long long x[3], y[3], z[3];
  for (int a = 0; a < 3; a++) {
    scanf("%lld%lld%lld", &x[a], &y[a], &z[a]);
  }
  long long needspeed = y[0] / x[0];
  if (z[0] <= needspeed) {
    printf("0\n");
    return 0;
  }
  long long speed1 = y[1], speed2 = y[2];
  if (speed1 > needspeed && speed2 > needspeed) {
    printf("-1\n");
    return 0;
  }
  if (speed1 > speed2) {
    swap(speed1, speed2);
    swap(x[1], x[2]);
    swap(y[1], y[2]);
    swap(z[1], z[2]);
  }
  long long n = x[0] / x[1] + 1;
  long long ans = 1e17;
  for (long long a = 0; a <= n; a++) {
    long long num = z[1] * a;
    if (z[0] <= y[2]) {
      if (a * x[1] * y[1] + (x[0] - x[1] * a) * z[0] <= y[0])
        ans = min(num, ans);
      continue;
    }
    long long l = 0, r = 1e7;
    while (l <= r) {
      long long mid = (l + r) / 2;
      if (((x[0] - a * x[1] - x[2] * mid) <= 0 &&
           a * x[1] * y[1] + (x[0] - a * x[1]) * y[2] <= y[0]) ||
          y[0] - a * x[1] * y[1] - mid * x[2] * y[2] >=
              max((long long)0, (x[0] - a * x[1] - x[2] * mid) * z[0])) {
        r = mid - 1;
        ans = min(num + mid * z[2], ans);
      } else
        l = mid + 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
