#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; ll H, W, LA, LB, KA, KB; bool f(ll a, ll b) { return H * W >= min(H, a * LA) * min(W, b * LB) + a * KA + b * KB; } int main() { cin >> H >> W >> LA >> LB >> KA >> KB; ll ans = LLONG_MAX; if (KA == 0 && KB == 0) { int a = (H + LA - 1) / LA; int b = (W + LB - 1) / LB; cout << a + b << endl; return 0; } for (ll a = 0; a <= H; ++a) { if (a * KA >= H * W) { ans = min(ans, a); } else { ll ok = H * W; ll ng = 0; while (abs(ok - ng) >= 2) { ll x = (ok + ng) / 2; ll cnt = min(H, a * LA) * min(W, x * LB) + a * KA + x * KB; if (cnt >= H * W) { ok = x; } else { ng = x; } } if (f(a, ok)) { ans = min(ans, a + ok); } } } for (ll b = 0; b <= W; ++b) { if (b * KB >= H * W) { ans = min(ans, b); } else { ll ok = H * W; ll ng = 0; while (abs(ok - ng) >= 2) { ll x = (ok + ng) / 2; ll cnt = min(H, x * LA) * min(W, b * LB) + x * KA + b * KB; if (cnt >= H * W) { ok = x; } else { ng = x; } } if (f(ok, b)) { ans = min(ans, b + ok); } } } cout << ans << endl; return 0; }