import java.util.* fun main(args: Array) { val cin = Scanner(System.`in`) val length :Int = Integer.parseInt(cin.next()) val startIndex :Int = Integer.parseInt(cin.next()) -1 val brackets :String = cin.next() val startBracket = brackets.get(startIndex) val direction :Int = if(startBracket.equals('(')) 1 else -1 var index = startIndex var counter :Int = 0 /* println(brackets) println("brackets length = " + length) println("start index = " + (startIndex + 1)) println("start bracket = " + brackets.get(startIndex)) println("direction = " + direction) */ do { index += direction //println("now index = " + index) counter += if(brackets.get(index).equals(startBracket)) 1 else -1 //println("counter = " + counter) } while(counter > -1) println (index + 1) }