#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include #include using namespace std; using ll=long long; using ld=long double; using st=string; using P=pair; typedef atcoder::modint mint; ll inf=9e18; template auto vec(const ll (&sizes)[s], const T& init = T()){ if constexpr(i < s) return vector(sizes[i], vec(sizes, init)); else return init; } int main(){ ll R,p,q,a,b,c,d; cin>>R>>p>>q>>a>>b>>c>>d; ll upper=(a+b+c+d)/3; ll l=0,r=min(upper,R/p)+1; ll x=(l+r)/2; while(l+1