N,K = map(int,input().split()) S = [""]+list(input()) init = S[K] index = K cnt = 1 if init==")": bct = -1 else: bct = 1 while True: index += bct if init==S[index]: cnt+=1 else: cnt-=1 if cnt==0: break print(index)