#C13601. Maximum Parentheses Nesting Depth

    ID: 43158 Type: Default 1000ms 256MiB

Maximum Parentheses Nesting Depth

Maximum Parentheses Nesting Depth

Given an arithmetic expression as a string, determine the maximum depth of nested parentheses in the expression. For example, the expression (1+2) has a maximum depth of 1, while an expression with no parentheses returns 0.

The problem involves counting the increments when encountering an opening parenthesis ( and decrements for a closing parenthesis ). Formally, if you denote the current depth as \( d \), then for each ( you increase \( d \) by 1, and for each ) you decrease \( d \) by 1. The answer is the maximum value of \( d \) encountered during processing.

You are required to read the input from stdin and output the result to stdout.

inputFormat

The input consists of a single line containing an arithmetic expression string. The expression may contain digits, operators, spaces, and parentheses.

outputFormat

Output a single integer which represents the maximum nesting depth of parentheses in the provided expression.

## sample
(1+2)
1