854. Parentheses Score

1

Medium

Vishal wants to calculate the score of a string containing balanced parentheses. Assist Vishal in determining the final score. The score is defined as follows:
1. Each pair of parentheses '()' has a score of 1.
2. The score of a string AB is equal to the sum of the scores of A and B, where A and B are two balanced parentheses strings.
3. The score of a string (A) is equal to 2 times the score of A, where A is a balanced parentheses string.

Input Format

A string.

Output Format

Output a single integer representing the score of the string.

Example

Input

()()

Output

2

Constraints

2 <= s.length <= 50
s consists of only '(' and ')'.
Loading...

View Submissions

Console