SDE Path

Maximum Nesting Depth of Parentheses

Easy

Maximum Nesting Depth of Parentheses

Given a valid parentheses expression, find its maximum nesting depth.

Input format

A single line containing a valid parentheses string (may also contain digits and + or *).

Output format

Print the maximum nesting depth of the parentheses.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
(1+(2*3)+((8)/4))+1
Expected output
3
Example 2
Input
(1)+((2))+(((3)))
Expected output
3