E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.
import sys

to_pay = None
number_of_yen = None

lines = []
while True:
  try:
    line = input()
  except EOFError:
    break
    
  if line:
    lines.append(line)
  else:
    break
number_of_yen = int(lines.pop())
to_pay = int(lines.pop())

if (to_pay - number_of_yen) % 500 is 0:
  print('YES')
else:
  print('NO')
  

n = int(input())
a = int(input())
 
print("Yes" if n%500 <= a else "No")