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