#include #include using namespace std; using ll = long long; int main(){ ll h, w, la, lb, ka, kb; cin >> h >> w >> la >> lb >> ka >> kb; int ans = 1 << 30; for(int x = 0; x <= 2e6; x++){ int ac = 2e6, wa = -1; while(ac-wa > 1){ int wj = (ac+wa)/2; ll z = ka*x+kb*wj+min(la*x, h)*min(lb*wj, w); (h*w <= z ? ac : wa) = wj; } ans = min(ans, x+ac); } cout << ans << endl; return 0; }