N, K = list(map(int, input().split())) S = input() result = 0 k = K - 1 if S[k] == '(': nesting = 0 for i in range(k, N): if S[i] == '(': nesting += 1 else: nesting -= 1 if nesting == 0: result = i + 1 break else: nesting = 0 for i in range(k, -1, -1): if S[i] == '(': nesting -= 1 if nesting == 0: result = i + 1 break else: nesting += 1 print(result)