s=[] n,k=gets.split.map(&:to_i) k-=1 gets.chomp.chars.each_with_index{|c,idx| if c==?( s.push [c,idx] else d,jdx=s.pop if idx==k p jdx+1 exit end if jdx==k p idx+1 exit end end }