Problem:
Score: 100 points

Problem Statement

E869120 has A 1-yen coins and infinitely many 500-yen coins.

Determine if he can pay exactly N yen using only these coins.

Constraints

N is an integer between 1 and 10000 (inclusive).

A is an integer between 0 and 1000 (inclusive).

Input

Input is given from Standard Input in the following format:

N
A

Output

If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No.

Sample Input 1

2018
218

Sample Output 1

Yes

We can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.

Sample Input 2

2763
0

Sample Output 2

No

When we have no 1-yen coins, we can only pay a multiple of 500 yen using only 500-yen coins. Since 2763 is not a multiple of 500, we cannot pay this amount.

Sample Input 3

37
514

Sample Output 3

Yes

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AIZUproject07
{
    class Program
    {
        //static string T;
        /*static void Main()
        {
            int count = 0;
            bool flag = false;
            string In = Console.ReadLine();
            string[] s = Console.ReadLine().Split();
            int[] aa = s.Select(int.Parse).ToArray();
            while (true)
            {
                for (int i = 0; i < aa.Length; i++)
                {
                    if (aa[i] % 2 != 0)
                    {
                        flag = true;
                    }
                    
                }
                aa = aa.Select(n => n / 2).ToArray();
                if (flag == true) break;
                count++;
            }
            Console.WriteLine(count);
        }*/
        /*static void Main()
        {
            int sum = 0;
            int count = 0;
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string C = Console.ReadLine();
            string D = Console.ReadLine();
            int AA = int.Parse(A);
            int BB = int.Parse(B);
            int CC = int.Parse(C);
            int DD = int.Parse(D);
            for(int i = 0;i<=AA;i++)
            {
                for (int j=0;j<=BB;j++)
                {
                    for (int k =0;k<=CC;k++)
                    {
                        sum = i * 500 + j * 100 + k * 50;
                        if (sum == DD) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }*/
        /*static void Main()
        {
            int ans1 = 0;
            int ans2 = 0;
            string[] s = Console.ReadLine().Split();
            int[] intArray = s.Select(int.Parse).ToArray();
            for (int i = 1;i<=intArray[0];i++)
            {
                ans1 = 0;
                if (i >= 10 && i <100)
                {
                    var aaa = i % 10;
                    var bbb = i / 10;
                    ans1 = aaa + bbb;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
                if (i >= 100 && i<1000)
                {
                    var aaa = i % 10;
                    var bbb = i / 10;
                    var ccc = bbb % 10;
                    var ddd = bbb / 10;
                    ans1 = aaa + ccc + ddd;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
                if (i >= 1000 && i <10000)
                {
                    var aaa = i % 10;//4
                    var bbb = i / 10;
                    var ccc = bbb % 10;//3
                    var ddd = bbb / 10;
                    var eee = ddd % 10;//2
                    var fff = ddd / 10;//1
                    ans1 = aaa + ccc + eee + fff;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
                if (i == 10000)
                {
                    ans1 = 1;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
                if (i < 10)
                {
                    ans1 = i;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
            }
            Console.WriteLine(ans2);
        }*/
        /*static void Main()
        {
            int sum = 0;
            bool test = false;
            string[] aa = Console.ReadLine().Split();
            int N = int.Parse(aa[0]);
            int Y = int.Parse(aa[1]);
            int Yukichi = Y / 10000;
            int Ichiyo = Y / 5000;
            int Hideyo = Y / 1000;
            int x = 0;
            int y = 0;
            int z = 0;
            for (int i = 0;i<=Yukichi;i++)
            {
                for (int j =0;j<=Ichiyo;j++)
                {
                    for (int k =0;k<=Hideyo;k++)
                    {
                        sum = 10000 * i + 5000 * j + 1000 * k;
                        if (sum == Y && i+j+k < N)
                        {
                            x = i;
                            y = j;
                            z = k;
                            //Console.WriteLine(i + " " + j + " " + k);
                            test = true;
                        }
                    }
                }
            }
            if (test == true)
            {
                Console.WriteLine(x + " " + y + " " + z);
            }
            if (test == false)
            {
                Console.WriteLine("-1 -1 -1");
            }
        }*/
        /*static void Main()
        {
            string[] aa = Console.ReadLine().Split();
            int N = int.Parse(aa[0]);
            int Y = int.Parse(aa[1]);
            int X = 0;
            int Z = 0;
            int b = 0;
            int d = 0;
            X = Y / 10000;
            var a = Y - (X*10000);
            if (a != 0 || Y < 10000)
            {
                b = a / 5000;
                var cc = a - (b * 5000);
                if (cc != 0 || a < 5000)
                {
                    d = cc / 1000;
                    var gg = cc - (d * 1000);
                    if (gg != 0 ||  cc<1000)
                    {
                        Console.WriteLine("-1 -1 -1");
                    }
                    else if (X + b + d <= N)
                    {
                        Console.WriteLine(X + " " + b + " " + d);
                    }
                    else if (X + b + d > N)
                    {
                        Console.WriteLine("-1 -1 -1");
                    }
                }
                else if (X + b <= N)
                {
                    Console.WriteLine(X +" "+ b +" "+"0");
                }
                else if (X + b > N)
                {
                    Console.WriteLine("-1 -1 -1");
                }
            }
            else if (X <= N)
            {
                Console.WriteLine(X +" "+0+" "+0);
            }
            else if (X>N)
            {
                Console.WriteLine("-1 -1 -1");
            }
        }*/
        /*static void Main()
        {
            string s = Console.ReadLine();

            var Ans = s.Replace("eraser", "").Replace("dreamer", "").Replace("dreamer", "").Replace("erase", "").ToString();
            if (Ans == null) Console.WriteLine("YES");
            else Console.WriteLine("NO");*/

        //List<string> str = new List<string>(); || s.Substring(5, 1) == ""
        //string NN = new string(s); || s.Substring(5,1) == ""
        /*while (true) { 
            while (true)
            {
                    if (s.StartsWith("dream") && (s.Substring(5,2) != "er" ))
                    {
                        count++;
                        var f = s.Remove(0, 5);
                        s = f;
                        break;
                    }
                    if (s.StartsWith("dreamer"))
                    {

                        var n = s.Remove(0, 7);
                        s = n;
                        break;
                    }
                    if (s.StartsWith("erase") || (s.Substring(5,1) != "r" ))
                    {
                        count2++;
                        var f1 = s.Remove(0, 5);
                        s = f1;
                        break;
                    }
                    if (s.StartsWith("eraser"))
                    {

                        var f2 = s.Remove(0, 6);
                        s = f2;
                        break;
                    }
                else
                {
                    tt = true;
                    break;
                }
            }
            if (s.Length == 0)
            {
                Console.WriteLine("YES");
                break;
            }
            if (tt)
            {
                Console.WriteLine("NO");
                break;
            }
        }*/
        //Console.WriteLine(count+","+count2);
        //}

        //86C
        /*static void Main()
        {
            /*string aa = Console.ReadLine();
            List<int[]> nn = new List<int[]>();
            for (int i = 0;i<aa.Length;i++)
            {
                string[] str = Console.ReadLine().Split();
                int[] intstr = str.Select(int.Parse).ToArray();
                nn.Add(intstr);
            }
            var a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var num = a1[0];
            var list = new List<int[]>(num);
            for (int i=0;i<num;i++)
            {

            }
        }*/
        /*static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var array = input.Select(int.Parse).ToArray();
            int num = array[0] * 100 + array[1] * 10 + array[2] * 1;
            if (num % 4 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }*/
        static void Main()
        {
            var input = Console.ReadLine();
            var a = Console.ReadLine();
            int N = int.Parse(input);
            int A = int.Parse(a);
            bool flag = false;
            for (int i = 0;i < A;i++ )
            {
                var Ans = N - i;
                if (Ans % 500 == 0)
                {
                    Console.WriteLine("Yes");
                    flag = true;
                    break;
                }
            }
            if (flag == false)
            {
                Console.WriteLine("No");
            }

        }
    }
}