pa=[int(x) for x in input().split()] pb=[500,100,50,10,5,1] def rG(G,i): nA=G//pb[i] nA=min(nA,pa[i]) return G-nA*pb[i] G=pa[6] for i in range(6): G=rG(G,i) if G==0: break print("NO" if G else "YES")