inpl = lambda: list(map(int,input().split())) N, K = inpl() S = input() if S[K-1] == '(': i = K-1 else: i = 0 pool = [i] for j in range(i+1,N): if S[j] == '(': pool.append(j) else: p = pool.pop() if j == K-1: print(p+1) break elif p == K-1: print(j+1) break