defmodule Main do
  def main do
    n = IO.read(:line) |> String.trim
    a = IO.read(:line) |> String.trim
    n = String.to_integer(n)
    a = String.to_integer(a)
    if rem(n, 500) <= a do
      IO.puts("Yes")
    else
      IO.puts("No")
    end
  end
end
