import sys, math sys.set_int_max_str_digits(0) N, K = map(int, input().split()) S = input() stack = [] taiou = [0]*(N + 1) for i, s in enumerate(S, 1): if s == '(': stack.append(('(', i)) else: if stack and stack[-1][0] == '(': j = stack[-1][1] taiou[i] = j taiou[j] = i stack.pop() print(taiou[K])