import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); String s = sc.next(); int ans = 0; if(s.charAt(K - 1) == '(') { int p = 1; for(int i = K; i < N; i++) { if(s.charAt(i) == '(') { p++; } else { p--; } if(p == 0) { ans = i + 1; break; } } } else { int p = -1; for(int i = K - 2; i >= 0; i--) { if(s.charAt(i) == '(') { p++; } else { p--; } if(p == 0) { ans = i + 1; break; } } } System.out.println(ans); } }