#include #include using namespace std; using namespace atcoder; using ll = long long; using ull = unsigned long long; using ld = long double; using mint = modint998244353; // using mint = modint1000000007; constexpr ll INF = (1LL << 60); constexpr int INF32 = (1 << 30); template using vc = vector; template using vv = vector>; using vi = vc; using vvi = vv; using vl = vc; using vvl = vv; using vs = vc; using vvs = vv; using vb = vc; using vvb = vv; using vmint = vc; using vvmint = vv; using pii = pair; using pll = pair; #define rep(i,n) for(ll i=0; i<(ll)(n); i++) #define drep(i,n) for(ll i=(ll)(n)-1; i>=0; i--) #define rrep(i,n) for(ll i=1; i<=(ll)(n); i++) #define nfor(i,a,b) for(ll i=(ll)(a); i<(ll)(b); i++) #define dfor(i,a,b) for(ll i=(ll)(a)-1; i>=(ll)(b); i--) #define nall(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() template istream& operator>>(istream& is, vector& v) { for (auto& x : v) is >> x; return is; } template istream& operator>>(istream& is, pair& p) { return is >> p.first >> p.second; } template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; } void YES() { cout << "Yes\n"; } void NO() { cout << "No\n"; } void yn(bool ok) { cout << (ok ? "Yes" : "No") << '\n'; } template void print(const vector& v) { for (int i = 0; i < (int)v.size(); i++) { if (i) cout << ' '; cout << v[i]; } cout << '\n'; } template void print(const vector>& v) { for (const auto& row : v) { print(row); } } void print(ld x) { cout << fixed << setprecision(20) << x << '\n'; } ll R, P, Q, A, B, C, D; template ll binary_search_last_true(ll ok, ll ng, F is_ok) { // is_ok(ok) == true // is_ok(ng) == false while (abs((__int128)ok - ng) > 1) { ll mid = (ll)((__int128)ok + ((__int128)ng - ok) / 2); if (is_ok(mid)) ok = mid; else ng = mid; } return ok; } bool is_ok(ll K) { ll need = 0; need += max(0LL,K-A) + max(0LL,K-B) + max(0LL,K-C); if(need>D) return false; ll cost = 0; cost += K * P; cost += need * Q; if(cost>R) return false; return true; } int main() { cin >> R >> P >> Q >> A >> B >> C >> D; ll mx = max(max(A+D,B+D),C+D); ll ans = binary_search_last_true(0,mx+1,is_ok); cout << ans << endl; }