// #include using namespace std; using ll = long long; #define rep(i, n) for (int i=0; i<(int)(n); ++(i)) #define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i)) #define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i)) #define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i)) #define all(x) (x).begin(), (x).end() int main() { int h, w, la, lb; ll ka, kb; cin >> h >> w >> la >> lb >> ka >> kb; int lval = 0, rval = (h+la-1) / la + (w+lb-1) / lb; auto calc = [&](int ai, int bi) -> bool { ll tval = min((ll)ai*la, (ll)h) * min((ll)bi*lb, (ll)w); return (((ll)h * w - tval) <= (ai * ka + bi * kb)); }; while (rval-lval > 1) { int cval = rval - (rval-lval) / 2; bool ok = false; rep(i, cval+1) if (calc(i, cval-i)) { ok = true; break; } if (ok) rval = cval; else lval = cval; } cout << rval << endl; return 0; }