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