Iron Bars

No attempts yetTime limit1sMemory limit256 MB

Problem

You cut several iron bars with a laser. The bars are stacked from the bottom up, and the laser is fired straight down from above to cut them at once. The bars and the lasers satisfy the following conditions.

  • A bar rests only on a bar longer than itself.
  • When a bar rests on another bar, it lies entirely inside the lower bar, and the two do not share an endpoint.
  • Every bar is cut by at least one laser.
  • No laser meets the endpoint of any bar.

The figure below shows one arrangement that satisfies the conditions. The thick horizontal lines are the bars, the dots are the laser positions, and the vertical dashed arrows are the firing directions.

Such an arrangement is written out from left to right with parentheses.

  1. A laser is written as an opening parenthesis immediately followed by a closing parenthesis, (). Conversely, every () means a laser.
  2. The left end of a bar is an opening parenthesis ( and its right end is a closing parenthesis ).

The parenthesis string for the figure appears above the figure.

A bar breaks wherever a laser passes through it, so it falls apart into several pieces. In the example the two topmost bars break into 3 pieces and 2 pieces, and counting the rest the same way gives 17 pieces in total.

Given the parenthesis string of an arrangement, write a program that finds the total number of pieces.

Input

The first line contains the parenthesis string of the arrangement, written with no spaces. It holds at most 100,000 parenthesis characters.

Output

Print the total number of pieces on one line.