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