#include "bits/stdc++.h" using namespace std; #define int long long #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]; vector bs, cs; REP(i,11) { REP(j,101-i*10) { REP(k,10001-i*1000-j*100) { int c = i*1000 + j*100 + k; if (c == Db) { bs.push_back(D(i,j,k)); } if (c == Dc) { cs.push_back(D(i,j,k)); } } } } REP(i,11) REP(j,101-i*10) REP(k,10001-i*1000-j*100) { if (i >= B[0] && j >= B[1] && k >= B[2]) { int ni = i - B[0]; int nj = j - B[1]; int nk = k - B[2]; for (auto&& d : bs) { dp[ni + d.i][nj + d.j][nk + d.k] = max( dp[ni + d.i][nj + d.j][nk + d.k], dp[i][j][k] + 1); } } if (i >= C[0] && j >= C[1] && k >= C[2]) { int ni = i - C[0]; int nj = j - C[1]; int nk = k - C[2]; for (auto&& d : cs) { dp[ni + d.i][nj + d.j][nk + d.k] = max( dp[ni + d.i][nj + d.j][nk + d.k], dp[i][j][k] + 1); } } } int ans = 0; REP(i,A[0]+1) REP(j,A[1]+1) REP(k,A[2]+1) { ans = max(ans, dp[i][j][k]); } cout << ans << endl; return 0; }