L, K = map(int, input().split()) sho, amari = divmod(L, 2*K) if amari == 0: ans = (sho - 1)*K else: ans = sho*K print(ans)