N, K = map(int, input().split()) S = input() lcount = 0 rcount = 0 if K <= N // 2: for i in range(K): if S[i] == '(': lcount += 1 else: lcount -= 1 i = N-1 while lcount > 0 : if S[i] == ')': lcount -= 1 else: lcount += 1 i -= 1 print(i+2) else: for i in range(N-1, K-1, -1): if S[i] == ')': rcount += 1 else: rcount -= 1 i = 0 while rcount > 0: if S[i] == '(': rcount -= 1 else: rcount += 1 i += 1 print(i+1)