local t = {true} for i = 2, 5001 do t[i] = false end local a = {500, 100, 50, 10, 5, 1} for i = 1, 6 do local c = a[i] local num = io.read("*n") for j = 5001, 1, -1 do if t[j] then for k = num, 1, -1 do if j + k * c <= 5001 then t[j + k * c] = true end end end end end print(t[1 + io.read("*n")] and "YES" or "NO")