You are a researcher investigating algorithms on binary trees. A binary tree is a data structure consisting of branch nodes and leaf nodes. Every branch node has a left child and a right child, each of which is either a branch node or a leaf node. The root of a binary tree is the branch node that has no parent.
You are preparing for your presentation and you need to create a figure of binary trees using software. You have already made a figure representing a binary tree made up of one branch node and two leaf nodes (Figure 1). However, suddenly the function of your software to create figures broke. You are very upset because in hours you must present in front of a large audience.
You decide to create figures of binary trees using only the copy, shrink, and paste functions of the presentation tool. That is, you can only perform the following two types of operations:
Copy the current figure to the clipboard (the previously copied figure is overwritten)
Paste the copied figure (shrinking if needed), attaching the root of the pasted figure to a leaf node of the current figure. You can paste the copied figure multiple times.
Moreover, you decide to make the figure using the minimum number of paste operations, since pasting is very time-consuming. Your task is to calculate the minimum number of paste operations needed to produce the target binary tree figure.

Figure 1: initial state
For example, the answer for sample 1 (Figure 4) is , since you can create the target figure as shown below, and this is the minimum possible:

Figure 2: intermediate

Figure 3: intermediate

Figure 4: goal
The input consists of a single line representing a binary tree. The expression's grammar is specified by the following BNF:
<tree> ::= (<tree><tree>) | "()"Every input conforms to this syntax. You may assume that every tree in the input has at least branch node and no more than 10^5 branch nodes.
Output a single integer: the minimum possible number of paste operations to construct the given binary tree.
Example 1