# Here your code ! L, K = gets.chomp.split.map(&:to_i) t = L/K l = L%K ans = (t - t%2)/2*K ans -= K if L%(2*K) == 0 puts ans