solve :: String -> Int
solve s
  | length sList /= 2 = error $ show (length sList) ++ "wtf in solve"
  | b `mod` a == 0 = a + b
  | otherwise = b - a
  where
    sList = fmap read $ words s
    a = head sList
    b = last sList

main :: IO ()
main = do
  getLine >>= return.solve >>= print
