#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) __typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template inline void amin(T &x, U y) { if(y < x) x = y; } template inline void amax(T &x, U y) { if(x < y) x = y; } int main() { int A[3], D[2], B[2][3]; rep(k, 3) cin >> A[k]; rep(i, 2) { cin >> D[i]; rep(k, 3) cin >> B[i][k]; } int ans = 0; rep(s, 2) { int a[3] = { A[0], A[1], A[2] }; int cnt = 0; while(1) { bool ok = false; rep(ii, 2) { int i = s ^ ii; int d = D[i]; { int t = min(a[0], d / 1000); d -= t * 1000, a[0] -= t; } { int t = min(a[1], d / 100); d -= t * 100, a[1] -= t; } { int t = min(a[2], d / 1); d -= t * 1, a[2] -= t; } if(d != 0) { continue; } a[0] += B[i][0]; a[1] += B[i][1]; a[2] += B[i][2]; ++ cnt; ok = true; break; } if(!ok) break; } amax(ans, cnt); } printf("%d\n", ans); return 0; }