#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main() { ll H, W, LA, LB, KA, KB; cin >> H >> W >> LA >> LB >> KA >> KB; ll ans = LLONG_MAX; 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; } } 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; } } ans = min(ans, b + ok); } } cout << ans << endl; return 0; }