n, k = gets.split.map(&:to_i) s = gets stack = [] ans = [] s.each_char.with_index do |c, idx| stack.push(idx) if c == "(" ans = [stack.pop + 1, idx + 1] if c == ")" if ans[0] == k puts ans[1] exit 0 end if ans[1] == k puts ans[0] exit 0 end end