import Control.Monad import Data.List main = do [n, k] <- map read . words <$> getLine :: IO [Int] s <- getLine let x = s !! (k - 1) let s' = if x == '(' then drop k s else take (k - 1) s let result = if x == '(' then checkL s' 0 0 else checkR (reverse s') 0 0 putStrLn . show $ if x == '(' then result + k else (length s') - result + 1 checkL (c:cs) count no | c == '(' = checkL cs (count + 1) (no + 1) | c == ')' && count > 0 = checkL cs (count - 1) (no + 1) | otherwise = no + 1 checkR (c:cs) count no | c == ')' = checkR cs (count + 1) (no + 1) | c == '(' && count > 0 = checkR cs (count - 1) (no + 1) | otherwise = no + 1