N,K=map(int, input().split()) S=input() if S[K-1]=='(': a=S[K:] c=')' else: a=S[:K][::-1] c='(' w=1 n=0 for x in S[K:]: n+=1 w+=(-1 if x==c else 1) if w==0: break print(n+K)