const input = require("fs").readFileSync("/dev/stdin", "utf8");
// const input = '2018\n218';

function Main(input) {
  const [N, A] = input.split('\n').map(val => parseInt(val));
  console.log(N%500 === A?'Yes':'No');
}

// Don't edit this line!
Main(input);