N, K = gets.split.map( &:to_i ) S = gets stack = Array.new corresponds = Array.new( N ) S.split( "" ).each_with_index do | c, i | if c == '(' then stack.push( i ) elsif c == ')' # damn '\n' ! corresponds[i] = stack.last corresponds[ stack.last ] = i stack.pop end end puts corresponds[ K - 1 ] + 1