d=input().split() L=int(d[0]) K=int(d[1]) if L%(2*K)==0: print((L//(2*K))*K-K) else: print((L//(2*K))*K)