# import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,K = map(int,input().split()) S = list(input())[:-1] L = deque() R = deque() Y = defaultdict(lambda:-1) for i,s in enumerate(S): if s==')': j = L.pop() Y[j]=i Y[i]=j else: L.append(i) print(Y[K-1]+1)