Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/string-qavslar-chuqurligi

Bracket depth

Medium 1000 ms 128 MB 58%
Share

A string $s$ that is a correct bracket sequence is given (every ( has a matching )). Find its depth — the largest number of brackets open at the same time.

The level of opened and closed brackets and the maximum depth

Input

One line containing the string $s$.

Output

One integer.

Note

$2 \le |s| \le 2 * 10^{5}$
$s$ is a correct bracket sequence of the characters ( and )

Examples

Input #1
(()(()))
Output #1
3
Input #2
()()
Output #2
1

Sign in to submit a solution

Signing up is free and takes a minute.