N, K = map(int, input().split()) S = input() x = 1 i = 1 if S[K-1] == ')': while x != 0: if S[K-1-i] == ')': x += 1 else: x -= 1 i += 1 print(K - i + 1) else: while x != 0: if S[K-1+i] == '(': x += 1 else: x -= 1 i += 1 print(K + i - 1)