inputs = STDIN.readlines.map(&:chomp) l, k = inputs[0].split(/\s+/).map(&:to_i) def yuu_length(l, k) if l % (2 * k) == 0 (l / (2 * k) - 1) * k else (l / (2 * k)) * k end end puts yuu_length(l, k)