strip :: [a] -> a
strip [x] = x

main = do
    ns <- fmap (fmap (read :: String -> Int) . words) . lines <$> getContents
    let n = strip $ head ns
    let a = strip $ last ns
    let m = a `mod` 500
    if a >= m then
      putStrLn "Yes"
    else
      putStrLn "No"
