E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.
n = int(input())
a = int(input())

z = int(n%500)

if a == z:
  print('Yes')
  
else:
  print('No')
n = int(input())
a = int(input())
 
z = int(n%500)
 
if a >= z:
  print('Yes')
  
else:
  print('No')