import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Stack; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String[] firstLine = reader.readLine().split(" "); int N = Integer.parseInt(firstLine[0]); int K = Integer.parseInt(firstLine[1]); String[] S = reader.readLine().split(""); Stack stack = new Stack<>(); for (int i = 0; i < N; i++) { if (S[i].equals("(")) { stack.add(new Parenthesis(S[i], i + 1)); } else { Parenthesis parenthesis = stack.pop(); if (i + 1 == K) { System.out.println(parenthesis.index); break; } else if (parenthesis.index == K) { System.out.println(i + 1); break; } } } } } class Parenthesis { String value; int index; Parenthesis(String value, int index) { this.value = value; this.index = index; } @Override public String toString() { return "Parenthesis{" + "value='" + value + '\'' + ", index=" + index + '}'; } }