def min(a,b); a < b ? a : b; end C = [500,100,50,10,5,1] N = gets.split.map(&:to_i) G = N.pop m = 6.times.inject(G) do |rest,i| n = min(rest / C[i],N[i]) rest - C[i] * n end puts m.zero? ? :YES : :NO