import Debug.Trace
import Control.Monad
import Data.List
import Control.Applicative

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

func :: Int -> Int -> Int
func x y
  |mod y x == 0 = x + y
  |otherwise = y - x