n, k = gets.split.map(&:to_i) s = gets.chomp stack = [] a = Array.new(n) s.each_char.with_index do |e, idx| if stack.dig(-1, 0) == '(' && e == ')' x = stack.pop[1] a[x] = idx a[idx] = x else stack << [e, idx] end end puts a[k - 1] + 1