import Control.Applicative

main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine 
  putStrLn $ show (solve a b)

solve :: Int -> Int -> Int
solve a b = case b `mod` a of
  0 -> a + b
  _ -> b - a
