L = list(map(int,input().split())) g = L[-1] for x,c in zip([500,100,50,10,5,1],L): m = min(c,g//x) g -= m*x print("NO" if g else "YES")