l, k = map(int, input().split()) q, mod = divmod(l, 2*k) if mod == 0: print(l - 2*k) else: print(k*q)