#include using namespace std; #define INF 1234567890 #define ll long long ll N, M, LA, LB, KA, KB; int main() { ios::sync_with_stdio(0); cin.tie(0); cin.exceptions(ios::badbit | ios::failbit); cin >> N >> M >> LA >> LB >> KA >> KB; ll res = INF; for(ll i=0; i<=N+M; i++) { ll row = min(N, i*LA); ll lo = 0, hi = N+M; // lo : can't, hi : can for(int k=0; k<25; k++) { ll mid = lo+hi>>1; // can i+j ? ll j = mid; ll col = min(M, j*LB); ll del = row*col + KA*i + KB*j; if (del >= N*M) hi = mid; else lo = mid; } ll j = hi; ll col = min(M, j*LB); ll del = row*col + KA*i + KB*j; if (del >= N*M) res = min(res, i+j); } cout << res << "\n"; return 0; }