n,k=map(int,input().split()) s=input() count=0 if s[k-1]=="(": for i in range(k,n): if s[i]=="(": count+=1 elif s[i]==")": count-=1 if count==-1: print(i+1) break elif s[k-1]==")": s=s[::-1] for i in range(n-k+1,n): if s[i]==")": count+=1 elif s[i]=="(": count-=1 if count==-1: print(n-i) break