#include using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rrep(i,n) for(int i=(int)(n-1);i>=0;i--) #define ALL(v) v.begin(),v.end() #define RALL(v) v.rbegin(),v.rend() template using V=vector; template using VV=V>; using u128=__int128_t; using ll=long long; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll r,p,q,a,b,c,d; cin>>r>>p>>q>>a>>b>>c>>d; auto f=[&](ll x)->bool{ ll cost=x*p,e=d,f=0; if(a>x) e+=a-x; else f+=x-a; if(b>x) e+=b-x; else f+=x-b; if(c>x) e+=c-x; else f+=x-c; if(f>e) return false; cost+=q*f; if(cost>r) return false; return true; }; ll ok=0,ng=2e9; while(ng-ok>1){ ll mid=(ok+ng)/2; if(f(mid)) ok=mid; else ng=mid; } cout<