from Queue import Queue A1000,A100,A1=map(int,raw_input().split()) Db =int(raw_input()) B1000,B100,B1=map(int,raw_input().split()) Dc = int(raw_input()) C1000,C100,C1=map(int,raw_input().split()) dp = [[[-1 for i in xrange(10001)] for j in xrange(101)] for k in xrange(11)] best = [(-1,-1,-1) for i in xrange(10001)] q = Queue() dp[A1000][A100][A1]=0 ans = 0 q.put((0,A1000,A100,A1)) while q.empty()==False: dist,At,Ah,Ao = q.get() ans = max(ans,dist) price = At*1000+Ah*100+Ao*1 bt,bh,bo=best[price] if bt != -1 and ((bt==At and bh >= Ah) or (bh==Ah and bt>At) or (bo==Ao and bt>At)) : continue for at in range(min(At,Db/1000)+1): for ah in range( max(0,(Db-at*1000-Ao+99)/100), min(Ah,max(0,(Db-at*1000)/100))+1): ao=Db-at*1000-ah*100 if at > At or ah > Ah or ao > Ao: print at,At,ah,Ah,ao,Ao #print "see",At-at+B1000,Ah-ah+B100,Ao-ao+B1 if dp[At-at+B1000][Ah-ah+B100][Ao-ao+B1]==-1: dp[At-at+B1000][Ah-ah+B100][Ao-ao+B1]=dist+1 q.put((dist+1,At-at+B1000,Ah-ah+B100,Ao-ao+B1)) for at in range(min(At,Dc/1000)+1): for ah in range( max(0,(Dc-at*1000-Ao+99)/100), min(Ah,max(0,(Dc-at*1000)/100))+1): ao=Dc-at*1000-ah*100 if at > At or ah > Ah or ao > Ao: print at,At,ah,Ah,ao,Ao #print "see",At-at+C1000,Ah-ah+C100,Ao-ao+C1 if dp[At-at+C1000][Ah-ah+C100][Ao-ao+C1]==-1: dp[At-at+C1000][Ah-ah+C100][Ao-ao+C1]=dist+1 q.put((dist+1,At-at+C1000,Ah-ah+C100,Ao-ao+C1)) print ans