import sequtils,strutils var A = stdin.readline.split.map(parseInt) B = [500, 100, 50, 10, 5, 1] cnt = newSeqWith(6, 0) G = A[6] ans = false f = true while f: cnt[5] += 1 var p = 5 while cnt[p] > A[p]: if p == 0: f = false break cnt[p] = 0 cnt[p - 1] += 1 p -= 1 if f: var s = 0 for i in 0..5: s += cnt[i] * B[i] if s == G: ans = true if ans: echo "YES" else: echo "NO"