PL, K = map(int, input().split()) count = PL //(2 * K) if PL % (2 * K) == 0: print((count - 1) * K) else: print(count * K)