import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; public class No22 { public static void main(String[] args) throws IOException { //括弧の対応 String[] text = readStr(); int N = Integer.parseInt(text[0].split(" ")[0]) , K = Integer.parseInt(text[0].split(" ")[1]) , r = 0; String S = text[1]; Deque dq = new ArrayDeque<>(); for(int i = 0;i < N;i++) { if(S.charAt(i) == '(') { dq.push(i+1); }else { r = dq.pop(); if(i+1 == K || r == K) { r = i + 1 + r - K; break; } } } System.out.println(r); } public static String[] readStr() throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList list = new ArrayList<>(); do { list.add(br.readLine()); }while(br.ready()); br.close(); String[] text = new String[list.size()]; list.toArray(text); return text; } }