n,k = gets.split.map(&:to_i) s = gets.chomp hash = Hash.new() a = [] b = [] n.times{|i| if s[i] == '(' a.push(i + 1) else hash[a.pop] = i + 1 end } if s[k - 1] == '(' p hash[k] else p hash.invert[k] end