import math._ import util.control.Breaks._ import scala.collection.mutable.ArrayBuffer object Main { def main(args: Array[String]) = { val sc = new java.util.Scanner(System.in) val n, k = sc.nextInt val s = sc.next val xs = new ArrayBuffer[(Int, Char)] // (インデックス, 括弧文字) breakable { for (i <- 0 to s.length-1) s(i) match { case '(' => xs.append((i, '(')) case ')' => { assert(xs.last._2 == '(') if (i == k-1) { println(xs.last._1 + 1) break } if (xs.last._1 == k-1) { println(i+1) break } } xs.remove(xs.length-1) } } } }