n, k = map(int, input().split()) s = input() cnt = 1 if s[k-1] == "(": for i in range(k, n): if s[i] == "(": cnt += 1 else: cnt -= 1 if cnt == 0: print(i + 1) break else: s = s[::-1] for i in range(n-k+1, n): if s[i] == ")": cnt += 1 else: cnt -= 1 if cnt == 0: print(n - i) break