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