N = int(eval(input()))

A = int(eval(input()))

ret = 'No'

for a in range(A+1):

  if N%500==a:

    ret='Yes'

    break

print(ret)

N = int(eval(input()))

A = int(eval(input()))

if N%500 <= A:

  print('Yes')

else:

  print('No')
N = int(eval(input()))
A = int(eval(input()))
ret = "No"
for a in range(A + 1):
    if N % 500 == a:
        ret = "Yes"
        break
print(ret)

N = int(eval(input()))
A = int(eval(input()))
if N % 500 <= A:
    print("Yes")
else:
    print("No")

-ret = "No" -for a in range(A + 1): -    if N % 500 == a: -        ret = "Yes" -        break -print(ret) +if N % 500 <= A: +    print("Yes") +else: +    print("No")