#coding: utf-8 ##yuki_22 nk=map(int,raw_input().split()) s=raw_input() n=nk[0] k=nk[1] k=k-1 count=0 if s[k]=='(': for i in xrange(k,n): if s[i]=='(': count+=1 elif s[i]==')': count-=1 if count==0: rt=i break elif s[k]==')': for i in xrange(k,-1,-1): if s[i]==')': count+=1 elif s[i]=='(': count-=1 if count==0: rt=i break print rt+1