import Control.Applicative ((<$>), (<*>)) import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B main :: IO () main = solve <$> (map read . words <$> getLine) <*> B.getLine >>= print solve :: [Int] -> ByteString -> Int solve [n, k] s = f 1 [] u where u = B.unpack s f i xs (c:cs) = if c == '(' then f (i + 1) (i : xs) cs else if head xs == k then i else if i == k then head xs else f (i + 1) (tail xs) cs