N,K=map(int,input().split()) S=list(input()) cnt=1 if S[K-1]=="(": for i in range(K,N): if S[i]=="(": cnt+=1 else: cnt-=1 if cnt==0: print(i+1);exit() elif S[K-1]==")": S.reverse() for i in range(N-K+1,N): if S[i]==")": cnt+=1 else: cnt-=1 if cnt==0: print(N-i);exit()