n, k = gets.to_s.split.map(&.to_i) if n % (k * 2) == 0 puts k * (n // (k * 2) - 1) else puts k * (n // (k * 2)) end