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