def a(s): return 1 if s!=")" else -1 N,K=map(int,input().split()) S=input() s=K-1 t=a(S[s]) e=s+t c=t while 1: c+=a(S[e]) e+=t if c==0: break print(1+e-t)