fn main() { let mut nk = String::new(); std::io::stdin().read_line(&mut nk).ok(); let k: usize = nk.trim().split_whitespace().skip(1).next().unwrap().parse().unwrap(); let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let s: Vec = s.trim().chars().collect(); match s[k-1] { '(' => { let (_, target) = s.split_at(k); let mut count = 1; target.iter().enumerate().for_each(|pair| { let c = pair.1; if *c == ')' { count -= 1; } else { count += 1; } if count == 0 { println!("{}", k + pair.0 + 1); return; } }) }, ')' => { let (target, _) = s.split_at(k-1); let mut count = 1; target.iter().rev().enumerate().for_each(|pair| { let c = pair.1; if *c == ')' { count += 1; } else { count -= 1; } if count == 0 { println!("{}", k - pair.0 - 1); return; } }) }, _ => {} } }