import java.util.Scanner; public class Main { private String str; private int a; private int n; public void setStr(String str){ this.str = str; } public void setA(int a){ this.a = a; } public void setN(int n){ this.n = n; } public int run(){ int now_r = 0; int now_l = 0; int ans = 0; char[] s = str.toCharArray(); if(s[a] == '('){ now_l = 1; for(int i = a+1;i <= n;i++){ if(s[i] == '('){ now_l++; }else if(s[i] == ')'){ now_r++; } if(now_r == now_l){ ans = i; break; } } }else{ now_r = 1; for(int i = a-1;i >= 0;i--){ if(s[i] == '('){ now_l++; }else if(s[i] == ')'){ now_r++; } if(now_r == now_l){ ans = i; break; } } } return ans + 1; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); Main m = new Main(); int n = sc.nextInt(); m.setN(n); int a = sc.nextInt(); a--; m.setA(a); String str = sc.next(); m.setStr(str); System.out.println(m.run()); } }