def f(s, n) # p [s,n] return s.size - f(s.reverse.tr("()",")("), s.size - n - 1) - 1if s[n] == ?) i = n g = lambda{|depth| return i if depth < 0 i += 1 if s[i] == ?( g.(depth+1) else g.(depth-1) end } g.(0) end N, K = gets.split.take(2).map(&:to_i) S = gets[0,N] p f(S, K-1) + 1