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