#include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector VI; typedef vector VVI; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define FOR(i, f, t) for(int(i)=(f);(i)<(t);(++i)) #define RREP(i, n) for(int(i)=(n)-1;(i)>=0;--(i)) const int MOD = int(1e9+7); int A1000,A100,A1; int DB,DC; int B1000,B100,B1; int C1000,C100,C1; int memo[11][111][11111]; int dfs(int a1000, int a100, int a1){ int maxv = 0; if(memo[a1000][a100][a1] >= 0) return memo[a1000][a100][a1]; { int k1000 = a1000, k100 = a100, k1 = a1; int db = DB; while(k1000 && db >= 1000) k1000--, db -= 1000; while(k100 && db >= 100) k100--, db -= 100; if(k1 >= db) k1 -= db, db = 0; if(db == 0){ maxv = max(maxv, dfs(k1000+B1000,k100+B100,k1+B1))+1; } } { int k1000 = a1000, k100 = a100, k1 = a1; int dc = DC; while(k1000 && dc >= 1000) k1000--, dc -= 1000; while(k100 && dc >= 100) k100--, dc -= 100; if(k1 >= dc) k1 -= dc, dc = 0; if(dc == 0){ maxv = max(maxv, dfs(k1000+C1000,k100+C100,k1+C1))+1; } } return memo[a1000][a100][a1] = maxv; } int main(){ do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0); cin >> A1000 >> A100 >> A1; cin >> DB; cin >> B1000 >> B100 >> B1; cin >> DC; cin >> C1000 >> C100 >> C1; memset(memo, -1, sizeof(memo)); cout << dfs(A1000,A100,A1) << endl; return 0; }