def lscan; gets.split.map(&:to_i); end n, k = lscan if n.even? p [k+1, n/2].min else p [k+1, n].min end