n,k = gets.chomp.split(" ").map(&:to_i) s = gets.chomp stack = [] x = 1 a = -1 s.each_char do |c| if(c == "(") stack.push(x) else a = stack.pop end break if(x == k) x += 1 end x = n stack = [] b = -1 s.reverse.each_char do |c| if(c == ")") stack.push(x) else b = stack.pop end break if(x == (k)) x -= 1 end puts [a,b].max