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