n,k=map(int,input().split()) s=list(input()) ct=1 if s[k-1]=='(': for i in range(k,n): if s[i]==')': ct-=1 else: ct+=1 if ct==0: print(i+1) exit() else: for i in range(k-2,-1,-1): if s[i]=='(': ct-=1 else: ct+=1 if ct==0: print(i+1) exit()