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