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