function Main(input) {
input = input.split(/\n/);
var a = parseInt(input[0], 10);
var b = parseInt(input[1], 10);
var c = a - b;
if (a => b) {
  console.log(c % 500 === 0 ? "YES" : "NO");
} else {
  console.log("YES");
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));
