import java.io.*; import java.util.*; class Main22 { public static void out (Object o) { System.out.println(o); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line1 = br.readLine().split(" "); int n = Integer.parseInt(line1[0]); int k = Integer.parseInt(line1[1]); String s = br.readLine(); char startChar = s.charAt(k - 1); int end = startChar == '(' ? n - 1 : 0; int i = startChar == '(' ? k : k - 2; int cnt = 0; //out("i : " + i + "\tend : " + end); while (true) { char c = s.charAt(i); if (c == '(') { if (startChar == '(') { cnt++; } else if (cnt == 0) { out(i + 1); break; } else { cnt--; } } else { if (startChar == '(') { if (cnt == 0) { out(i + 1); break; } else { cnt--; } } else { cnt++; } } i = i < end ? i + 1 : i - 1; //out("cnt : " + cnt + "\ti : " + i); if (i < 0 || i >= n) break; } } }