#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main(){ ll H, W, la, lb, ka, kb, ans=1e18; cin >> H >> W >> la >> lb >> ka >> kb; for (ll i=0; i<=H+W; i++){ ll l=-1, r=H+W, c; while(r-l>1){ c = (l+r)/2; if (H*W - min(H, la*i) * min(W, lb*c) <= ka*i + kb*c) r=c; else l=c; } ans = min(ans, r+i); } cout << ans << endl; return 0; }