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