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