import Control.Applicative ((<$>), (<*>)) main :: IO () main = do solve <$> getl (map read . words) <*> getLine >>= print solve :: [Int] -> String -> Int solve [n, k] s = f 1 [] s where f i st (c:cs) = if c == '(' then f (i + 1) (i : st) cs else if head st == k then i else if i == k then head st else f (i + 1) (tail st) cs getl :: (String -> a) -> IO a getl f = f <$> getLine