시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB22131155.000%

문제

The number of parentheses and the level of nesting are usually a good indication of how complicated an expression is.

Given a string containing only “(”, “)” and blanks (spaces), compute its complexity. The complexity is defined as follows:

  • Each innermost set of parentheses adds 1 to the total complexity.
  • Each set of parentheses containing only innermost set of parentheses adds 2 to the total complexity, i.e., one level out will add 2 to the complexity.
  • Each set of parentheses at the next level out adds 3 to the complexity, and so on.

입력

There is only one input line; it contains a valid expression. The expression (string) will be 2-60 characters, each character being either “(”, “)” or blank (space). Note that the blanks can be anywhere but the string will not exceed 60 characters (including the blanks). Assume that there will be at least one set of parentheses in the input, i.e., the input will not be all blanks.

Note that a valid expression satisfies the following:

  1. All the parentheses are matched, i.e., every opening parenthesis has a corresponding closing parenthesis.
  2. The matched parentheses are in the correct order, i.e., an opening parenthesis comes before its corresponding closing parenthesis.

Note again that the input is a valid expression, i.e., you do not need to check for errors.

출력

Print the complexity of the expression.

예제 입력 1

()()()()()

예제 출력 1

5

예제 입력 2

        ( () ( ) () ( ) )

예제 출력 2

6

예제 입력 3

( (()) () (()) )

예제 출력 3

10

예제 입력 4

     ((())) () ( (()) () (()) )

예제 출력 4

17

예제 입력 5

(((((((((((((((((((())))))))))))))))))))

예제 출력 5

210

노트

Note: The last Sample Input has parentheses nested 20 levels.