L,K=map(int,input().split()) a=L//K//2*K if L-a*2<=0: if a-1<0: a=1 print(a-K) else: print(a)