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