# -*- coding: utf-8 -*- def solve(A, Db, B, Dc, C): LA = 10001 LB = 11 LC = 101 mx = 0 dp = [[[-1 for _ in xrange(LC)] for _ in xrange(LB)] for _ in xrange(LA)] dp[0][A[0]][A[1]] = A[2] for i in xrange(1, LA): for j in xrange(0, LB): for k in xrange(0, LC): if dp[i - 1][j][k] == -1: continue d = Db use1000 = min(j, d / 1000) d -= use1000 * 1000 use100 = min(k, d / 100) d -= use100 * 100 if d <= dp[i - 1][j][k]: # お使いが可能ならお使いをする dp[i][j - use1000 + B[0]][k - use100 + B[1]] = max(dp[i][j - use1000 + B[0]][k - use100 + B[1]], dp[i - 1][j][k] - d + B[2]) mx = max(mx, i) d = Dc use1000 = min(j, d / 1000) d -= use1000 * 1000 use100 = min(k, d / 100) d -= use100 * 100 if d <= dp[i - 1][j][k]: # お使いが可能ならお使いをする dp[i][j - use1000 + C[0]][k - use100 + C[1]] = max(dp[i][j - use1000 + C[0]][k - use100 + C[1]], dp[i - 1][j][k] - d + C[2]) mx = max(mx, i) return mx if __name__ == '__main__': A = map(int, raw_input().split()) Db = int(raw_input()) B = map(int, raw_input().split()) Dc = int(raw_input()) C = map(int, raw_input().split()) print solve(A, Db, B, Dc, C)