def rec(i, j, k): if memo[i][j][k]!=-1: return memo[i][j][k] res = 0 Db_ = Db use1000 = min(Db_//1000, i) Db_ -= use1000*1000 use100 = min(Db_//100, j) Db_ -= use100*100 if Db_<=k: use1 = Db_ res = max(res, rec(i-use1000+B1000, j-use100+B100, k-use1+B1)+1) Dc_ = Dc use1000 = min(Dc_//1000, i) Dc_ -= use1000*1000 use100 = min(Dc_//100, j) Dc_ -= use100*100 if Dc_<=k: use1 = Dc_ res = max(res, rec(i-use1000+C1000, j-use100+C100, k-use1+C1)+1) memo[i][j][k] = res return res A1000, A100, A1 = map(int, input().split()) Db = int(input()) B1000, B100, B1 = map(int, input().split()) Dc = int(input()) C1000, C100, C1 = map(int, input().split()) memo = [[[-1]*10001 for _ in range(101)] for _ in range(11)] print(rec(A1000, A100, A1))