module Main where
import Data.Char
int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[])

solver [n,a] = if n`mod`500 <= a then "Yes" else "No"