import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,K = map(int,readline().split()) S = read().rstrip().decode() stack = [(-1,'$')] pair = dict() for i,s in enumerate(S,1): if s == ')' and stack[-1][1] == '(': j = stack[-1][0] pair[i] = j pair[j] = i stack.pop() else: stack.append((i,s)) answer = pair[K] print(answer)