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