L,K=map(int,input().split()) k=(L//(K*2))*K - (L%(K*2)==0)*K print(k)