N,K=map(int,input().split()) S=list(input()) cnt=[0 for _ in range(N+1)] prev="(" for i,s in enumerate(S): if s=="(": if prev=="(":cnt[i]=cnt[i-1]+1 else:cnt[i]=cnt[i-1];prev="(" else: if prev==")":cnt[i]=cnt[i-1]-1 else:cnt[i]=cnt[i-1];prev=")" v=cnt[K-1] i=K while i=0: if cnt[i]==v: print(i+1);exit() i-=1