l, k = [int(x) for x in input().split()] if l % (k * 2) == 0: print(int((l / (k * 2) - 1) * k)) else: print(int((l // (k * 2)) * k))