n,k = gets.split.map(&:to_i) s = gets.chomp.chars stack = [] indexes = Array.new(n,-1) s.each_with_index do |v,i| if v == '(' stack.push(i) else half = stack.pop indexes[half] = i indexes[i] = half end end puts indexes[k-1] + 1