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