import math L, K = [int(x) for x in input().split()] num = math.ceil(L / K) if num % 2 == 1: ans = int(num / 2) * K else: if num == 2: ans = 0 ans = int((num / 2) - 1) * K print(ans)