import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, k = map(int, readline().split()) s = readline().rstrip().decode() cnt = 0 memo = [0] * n for i, ss in enumerate(s): if ss == ')': memo[i] = cnt cnt -= 1 else: cnt += 1 memo[i] = cnt if s[k - 1] == '(': for i, ss in enumerate(memo[k:]): if ss == memo[k - 1]: print(k + i + 1) break else: for i, ss in enumerate(memo[:k - 1][::-1]): if ss == memo[k - 1]: print(k - i - 1) break