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