J=lambda:list(map(int,input().split())) A=J() P=J() s=0 for p,a in sorted([p,a]for a,p in zip(A,P)):t=min(a,P[4]//p);P[4]-=t*p;s+=t print(s)