#include #define rep(i, a, n) for(ll i = a; i < (n); i++) using namespace std; using ll = long long; using P = pair; const int INF = 1001001001; const ll LINF = 1001002003004005006ll; //const int mod = 1000000007; //const int mod = 998244353; int main() { ll h, w, a, b, c, d; cin >> h >> w >> a >> b >> c >> d; ll ans = LINF; rep(i, 0, 1000005) { ll ub = LINF, lb = -1; while (ub - lb > 1) { ll mid = (ub + lb)>>1; if (i*c + mid*d + min((ll)i*a, h)*min(mid*b, w) >= h*w) ub = mid; else lb = mid; } ans = min(ans, i + ub); } cout << ans << endl; return 0; }