function Main(input) {
  const num = input.split("\n");
  const amari = parseInt(num[0] % 500, 10);
        itchien = parseInt(num[1], 10);
  if(amari > itchien){
    console.log("NO");
  } else {
    console.log("YES");
  }
}

function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
