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 = [-1] * n for i, ss in enumerate(s): memo[i] = cnt if ss == '(': cnt += 1 else: cnt -= 1 if s[k - 1] == '(': for i, v in enumerate(memo[::-1]): if memo[k - 1] == v: print(n - i - 1) break else: for i, v in enumerate(memo): if memo[k - 1] == v: print(i) break