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