import re N,K = map(int,input().split()) S = input() num = [x for x in range(1,N+1)] pattern = r"\(\)" pat = re.compile(pattern) while True: match = pat.search(S) s = match.start() e = match.end() if num[s] == K: print(num[e-1]) break elif num[e-1] == K: print(num[s]) break del num[s:e] S = S.replace('()','',1)