main = getLine >>= print . solve' . solve . map read . words where solve' n | n < 0 = 0 | otherwise = n solve :: [Int] -> Int solve [l, k] | m == 0 = h - k | otherwise = h - m where h = div l 2 + if odd l then 1 else 0 m = mod h k