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