import java.util.Scanner object no22{ def main(args: Array[String]) { val scan = new Scanner(System.in) val n,k = scan.nextInt val s = scan.next var a = scala.collection.mutable.ListBuffer[(Char,Int)]() for(i <- Range(0,n)) s(i) match{ case '(' => a:+=('(',i) case ')' => { if(a.last._2 == k-1){ println(i+1) return } if(i == k-1){ println(a.last._2+1) return } } a.remove(a.size-1) } } }