object Main extends App{
       val sc = new java.util.Scanner(System.in)
       val n, a = sc.nextInt()

       val ans = if((n-a)%500 == 0){
           "YES"
        }else{
           "NO"
           }
        println(ans)
        }