#coding:utf-8 N,K=map(int,raw_input().split()) S=raw_input() cnt,ans=0,0 if S[K-1] == '(': for i in S[K-1:]: cnt+=1 if i == '(': ans+=1 else: ans-=1 if ans == 0: print cnt+(K-1) break else: for i in S[:K][::-1]: cnt+=1 if i == ')': ans+=1 else: ans-=1 if ans == 0: print cnt-(K-1) break