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