function main (input) {
  var line = input.split('\n').map(Number);  
  var a = line[0];
  var b = line[1];
  
  while(a > 500) a -= 500;

  a <= b ? console.log('Yes') : console.log('No');
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));