_,a,b=`dd`.split f=->x,y{b[/.{#{N}}(?
#{x}\g
*#{y})/].size} p b[N=a.to_i-1])?f['\(','\)']:(N=b.size-1-N;b.reverse!;b.size-f['\)','\(']+1)