pB :: Int -> [Int] -> [(Char, Int)] -> Int pB k ns ((b,n'):bs) = if b == '(' then pB k (n':ns) bs else case ns of [] -> 0 (n:ns') -> if n == k then n' else if n' == k then n else pB k ns' bs main = do [n,k] <- (map read . words) <$> getLine s <- getLine putStrLn $ show $ pB k [] $ zip s [1..]