L, K = map(int, input().split()) twice_K = K * 2 result = 0 if L > twice_K: count = L // twice_K else: result = 0 if L % twice_K == 0: count -= 1 result = K * count print(result)