Balanced Braces#1271

Balanced Braces

1 second
64 megabytes
Very easy

You're given a non-empty string composed entirely of opening and closing braces. Your task is to find the minimum number of operations needed to make the string stable. The definition of being stable is as follows:

  1. An empty string is stable.

  2. If is stable, then is also stable.

  3. If and are both stable, then (the concatenation of the two) is also stable.

The following strings are stable: , , and ; but none of these are: , , nor .

The only operation allowed on the string is to replace an opening brace with a closing brace, or vice versa.

Input

Your program will be tested on one or more data sets. Each data set is described on a single line. The line is a non-empty string of opening and closing braces and nothing else. No string has more than braces. All sequences are of even length.

The last line of the input consists of one or more (minus signs).

Output

For each test case, print the following line:

where is the test case number (starting at one), and is the minimum number of operations needed to convert the given string into a stable one.

Examples

Example 1

Loading
Loading