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