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