from heapq import heappop,heappush N,K = map(int,input().split()) K -= 1 S = input() P = [-1] * N heap = [] cnt = 1 for i in range(N): if S[i] == '(': P[i] = cnt heappush(heap, -(cnt)) cnt += 1 else: P[i] = -heappop(heap) for i in range(N): if P[i] == P[K] and i != K: print(i+1) break