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