scan = string.gmatch(io.read(),"%d+") n = scan() - 0 k = scan() - 0 s = io.read() s = {s:byte(1,s.len(s))} l = string.byte("(") r = string.byte(")") result = 0 b = {} for i = 1, n do if s[i] == l then table.insert(b,i) elseif s[i] == r then local pop = table.remove(b) if k == pop then result = i break elseif k == i then result = pop break end end end print(result)