import Control.Monad

main = do
    [a, b] <- fmap read <$> words <$> getLine
    putStrLn $ show $ solve a b

solve :: Int -> Int -> Int
solve a b | b `mod` a == 0 = a + b
          | otherwise      = b - a
