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