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())

if N%100<=A:
    print("YES")
else:
    print("NO")
N = int(input())
A = int(input())

N_new = N%1000

if N_new<=A:
    print("Yes")
else:
    if N_new>=500:
        N_new -= 500
        if N_new<=A:
            print("Yes")
        else:
            print("No")
    else:
        print("No")