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