import Control.Monad import Control.Applicative import Data.List main ::IO() main=do [n,k] <- (map read . words) <$> getLine s <- getLine putStrLn $ show ( solve s k n ) solve :: String -> Int -> Int -> Int solve s k n = let res = f s [1..n] [] trgt = res !! (k-1) res2 = [snd x|x <- (zip res [1..n]),(fst x)==trgt, (snd x)/=k] in head res2 f:: String -> [Int] -> [Int] -> [Int] f "" _ _ = [] f s (x:xs) ys | (head s) == '(' = x:(f (tail s) xs (x:ys)) | otherwise = head ys : (f (tail s) xs (tail ys))