import math L, K = map(int,(input().split())) if L / K <= 2: ans = 0 else: if L % 2 == 0: ans = math.floor(L / K / 2 - 1) * K else: ans = math.floor(L / K / 2) * K print(ans)