L, k = [int(x) for x in input().split()] cnt = (L - 2 * k) // (2 * k) d = (L - 2 * k) % (2 * k) if d > 0: cnt += 1 print(cnt * k)