N,K = map(int,input().split()) S = list(input()) ls = [] pair = [-1]*(N) for i in range(N): ls.append((S[i],i)) if len(ls) >= 2: if ls[-1][0] == ')' and ls[-2][0] == '(': pair[ls[-1][1]] = ls[-2][1] pair[ls[-2][1]] = ls[-1][1] ls.pop() ls.pop() print(pair[K-1]+1)