#include using namespace std; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FORR(x,arr) for(auto&& x:arr) #define FOR(i,a,b) for (int i = (a); i < (b); i++) #define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--) #define REP(i,n) for (int i = 0; i < (n); i++) #define RREP(i,n) for (int i = (n)-1; i >= 0; i--) #define ALL(x) (x).begin(), (x).end() #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++) #define BIT(n) (1LL<<(n)) #define SZ(x) ((int)(x).size()) typedef long long ll; // ------------------------------------- int A1000, A100, A1; int Db; int B1000, B100, B1; int Dc; int C1000, C100, C1; int dp[11][101][10001]; template inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } int dfs(int a3, int a2, int a0) { if (dp[a3][a2][a0] != -1) return dp[a3][a2][a0]; int ret = 0; REP(i, a3+1) REP(j, a2+1) { int ij = i * 1000 + j * 100; if (ij <= Db && a0 >= Db - ij) amax(ret, dfs(a3-i+B1000, a2-j+B100, a0-(Db-ij)+B1) + 1); if (ij <= Dc && a0 >= Dc - ij) amax(ret, dfs(a3-i+C1000, a2-j+C100, a0-(Dc-ij)+C1) + 1); } return dp[a3][a2][a0] = ret; } int main() { cin >> A1000 >> A100 >> A1; cin >> Db; cin >> B1000 >> B100 >> B1; cin >> Dc; cin >> C1000 >> C100 >> C1; memset(dp, 0xff, sizeof(dp)); ll ans = dfs(A1000, A100, A1); cout << ans << endl; return 0; }