print('YNeos'[eval(input())%500>eval(input())::2])
n,a=list(map(int,open(0)));print(('YNeos'[n%500>a::2]))
print("YNeos"[eval(input()) % 500 > eval(input()) :: 2])

n, a = list(map(int, open(0)))
print(("YNeos"[n % 500 > a :: 2]))

-print("YNeos"[eval(input()) % 500 > eval(input()) :: 2]) +n, a = list(map(int, open(0))) +print(("YNeos"[n % 500 > a :: 2]))