rInt :: String -> Int
rInt = read

solve :: Int -> String -> Int
solve k s
    | last t == '(' = op 1 k d
    | otherwise     = cp 1 k (reverse (init t))
    where
        t = take k s
        d = drop k s

op :: Int -> Int -> String -> Int
op 0 k _ = k
op i k (x:xs)
    | x == ')'  = op (i - 1) (k + 1) xs
    | otherwise = op (i + 1) (k + 1) xs

cp :: Int -> Int -> String -> Int
cp 0 k _ = k
cp i k (x:xs)
    | x == '('  = cp (i - 1) (k - 1) xs
    | otherwise = cp (i + 1) (k - 1) xs

{--}
main = do
    [n, k] <- map rInt . words <$> getLine
    s <- getLine
    print $ solve k s