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