main :: IO() main = getLine >>= print.(\[x, y] -> (*y).f $ x `divMod` (y * 2)).map read.words where f (a, 0) = a - 1 f (a, _) = a