import Data.Array solve :: Int -> Array Int Char -> Int solve k a | a!k == '(' = right (k+1) 1 - 1 | a!k == ')' = left (k-1) 1 + 1 | otherwise = undefined where right i 0 = i right i c | a!i == '(' = right (i+1) (c+1) | a!i == ')' = right (i+1) (c-1) | otherwise = undefined left i 0 = i left i c | a!i == ')' = left (i-1) (c+1) | a!i == '(' = left (i-1) (c-1) | otherwise = undefined main :: IO () main = do [n,k] <- map read . words <$> getLine :: IO [Int] s <- getLine :: IO String let a = listArray (1,n) s :: Array Int Char print $ solve k a