L, K = map(int, input().split()) nq, nr = divmod(L, (K * 2)) if (nr == 0) and (nq >= 1): print((nq - 1) * K) else: print(nq * K)