#include "bits/stdc++.h" using namespace std; #define REP(i, n) for(int i=0; i<(n); i++) struct D { int i, j, k; D(){}; D(int _i, int _j, int _k):i(_i),j(_j),k(_k){}; }; int N,T; int dp[21][211][21111]; int A[3], B[3], C[3]; int Db, Dc; signed main() { REP(i,3) cin >> A[i]; cin >> Db; REP(i,3) cin >> B[i]; cin >> Dc; REP(i,3) cin >> C[i]; REP(i,11) REP(j,101-i*10) REP(k,10001-i*1000-j*100) { int bi = min(i, Db / 1000); int bj = min(j, (Db - bi*1000) / 100); int bk = Db - bi * 1000 - bj * 100; if (k >= bk) { int ni = i - bi + B[0]; int nj = j - bj + B[1]; int nk = k - bk + B[2]; dp[i][j][k] = max(dp[i][j][k], dp[ni][nj][nk] + 1); } int ci = min(i, Dc / 1000); int cj = min(j, (Dc - ci*1000) / 100); int ck = Dc - ci * 1000 - cj * 100; if (k >= ck) { int ni = i - ci + C[0]; int nj = j - cj + C[1]; int nk = k - ck + C[2]; dp[i][j][k] = max(dp[i][j][k], dp[ni][nj][nk] + 1); } } cout << dp[A[0]][A[1]][A[2]] << endl; return 0; }