N, K = list(map(int, input().split())) S = str(input()) p = 1 if S[K-1] == "(": for n in range(K,N): if S[n] == "(": p += 1 else: p -= 1 if p == 0: print(n+1) break else: S = S[::-1] for n in range(N-K+1, N): if S[n] == ")": p += 1 else: p -= 1 if p == 0: print(N-n) break