import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines a1000, a100, a1=map(int, readline().split()) db=int(readline()) b1000, b100, b1=map(int, readline().split()) dc=int(readline()) c1000, c100, c1=map(int, readline().split()) dp={} def solve(x1000, x100, x1): if (x1000, x100, x1) in dp: return dp[(x1000, x100, x1)] ans=0 b=db z1000=min(b//1000, x1000) b-=z1000*1000 z100=min(b//100, x100) b-=z100*100 z1=min(b, x1) b-=z1 if b==0: ans=max(ans, solve(x1000-z1000+b1000, x100-z100+b100, x1-z1+b1)+1) c=dc z1000=min(c//1000, x1000) c-=z1000*1000 z100=min(c//100, x100) c-=z100*100 z1=min(c, x1) c-=z1 if c==0: ans=max(ans, solve(x1000-z1000+c1000, x100-z100+c100, x1-z1+c1)+1) dp[(x1000, x100, x1)]=ans return ans print(solve(a1000, a100, a1))