"use strict"

const Main = (input)=>{
const Array =input.split(/\n/)
const N =Array[0]
const A =Array[1]
const result = (N%500) < A
console.log(result?"YES":"NO" )
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
}