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