Auxiliary Question of the Universe

Time limit1sMemory limit128 MB

Problem

Scientists once found the Ultimate Question of Life, the Universe, and Everything. Unsatisfied, they commissioned a small computer to compute a more specific auxiliary question. The machine ran, but its answer came back corrupted — only a fragment of the correct question survived.

The constructors believe the original question can be recovered from this fragment by inserting additional characters, without reordering or deleting any of the fragment's own characters. In other words, the fragment must appear as a subsequence of the reconstructed question. They also believe the question is an arithmetic expression that uses only addition (no multiplication), described by the following grammar:

<expression> ::= <term> | <term> + <expression>
<term> ::= <number> | ( <expression> )
<number> ::= 0 ... 9 [ <number> ]

You may insert any of the characters +, (, ), or a digit 09, at any positions (including before or after the fragment). Determine the minimum number of characters that must be inserted so that the result is a valid expression under this grammar. Such a reconstruction always exists, so this minimum is always well defined.

Input

A single line containing the surviving fragment: a non-empty string of at most 1000 characters, made up only of the characters +, (, ), and the digits 09.

Output

Print a single integer — the minimum number of characters that must be inserted into the fragment so that it becomes a valid expression under the grammar, while keeping the fragment's characters as a subsequence.