judge :: Bool -> (String,String) -> String
judge f (ts,fs) = case f of
  True -> ts
  False -> fs

canPay :: Int -> Int -> Bool
canPay n a = n `mod` 500 <= a

main = do
  contents <- getContents
  let
    [n,a] = map (read :: String -> Int) $ lines contents
    ret = canPay n a
  putStrLn $ judge ret ("Yes","No")
  