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