#include using namespace std; typedef pair P; typedef pair> PP; typedef long long ll; const double EPS = 1e-8; const int INF = 1e9; const int MOD = 1e9+7; int dy[] = {0,1,0,-1}; int dx[] = {1,0,-1,0}; int Db,Dc; vector A,B,C; int dfs(int A1000,int A100,int A1){ int ret = 0; int db = Db; int a1000 = A1000,a100 = A100,a1 = A1; while(db >= 1000 && a1000 > 0){db -= 1000;a1000--;} while(db >= 100 && a100 > 0){db -= 100;a100--;} int t = min(a1,db); a1 -= t; db -= t; if(db == 0)ret = max(ret,dfs(a1000+B[0],a100+B[1],a1+B[2])); int dc = Dc; a1000 = A1000;a100 = A100;a1 = A1; while(dc >= 1000 && a1000 > 0){dc -= 1000;a1000--;} while(dc >= 100 && a100 > 0){dc -= 100;a100--;} t = min(a1,dc); a1 -= t; dc -= t; if(dc == 0)ret = max(ret,dfs(a1000+C[0],a100+C[1],a1+C[2])); return ret + 1; } int main(void) { A.resize(3);B.resize(3);C.resize(3); cin >> A[0] >> A[1] >> A[2]; cin >> Db; cin >> B[0] >> B[1] >> B[2]; cin >> Dc; cin >> C[0] >> C[1] >> C[2]; // vector>>dp(A[0]+1,vector>(A[1]+1,vector(A[2]+1))); // for(int i=A[0];i>0;i--){ // for(int j=A[1];j>0;j--){ // for(int k=A[2];k>0;k--){ // dp[i][j][k] // } // } // } cout << dfs(A[0],A[1],A[2]) << endl; return 0; }