A = list(map(int, input().split())) g = A.pop() JPY = [500, 100, 50, 10, 5, 1] for a, j in zip(A, JPY): for i in range(a): if g >= j: g -= j print("YNEOS"[g::2])