import Control.Applicative import Control.Monad import Data.List import Data.Maybe paren :: ([Int], [(Int, Int)]) -> (Char, Int) -> ([Int], [(Int, Int)]) paren (s : ss, res) (x, i) | x == '(' = (i : s : ss, res) | otherwise = (ss, (s, i) : res) solve :: Int -> Int -> String -> Int solve n k s = if a == k then b else a where (a, b) = fromJust . find (\ (a, b) -> a == k || b == k) . snd . foldl' paren ([-1], []) $ zip s [1 .. n] main = do [n, k] <- map read . words <$> getLine :: IO [Int] s <- getLine print $ solve n k s