#coding=UTF-8 #Brain Fuc○の角括弧の対応についての私の解決策を書いてみようかしら mojir=input() hyo=mojir.split(' ') N=int(hyo[0]) K=int(hyo[1]) S=input() if S[K-1]=='(': depth=1 for idx in range(K,N,1): if S[idx]=='(': depth=depth+1 elif S[idx]==')': depth=depth-1 if depth==0: #お巡りさん、こいつです print(idx+1)#0-orginに注意 break else: depth=1 for idx in range(K-2,-1,-1): if S[idx]==')': depth=depth+1 elif S[idx]=='(': depth=depth-1 if depth==0: #お巡りさん、こいつです print(idx+1)#0-orginに注意 break