Correcting Parenthesization#1551

Correcting Parenthesization

1 second
128 megabytes
Easy

Given a string consisting of parentheses, your task is to obtain a well-formed string by changing the minimum number of characters. Deleting or inserting characters is not allowed.

There are three types of parentheses: round , square , and curly . Each pair consists of an opening parenthesis (, , ) and a closing parenthesis (, , ).

A well-formed string is defined by the following rules:

As examples, the strings "([{}])", "", and "(){}[]" are well-formed, while "([}])", "([)]", and "{" are not. For the given string, find the minimum number of changes required to obtain a well-formed string.

Input

Each line contains a string with an even number of symbols: , , , , , . The length of each line does not exceed .

Output

For each line, output a single integer: the minimum number of characters that must be changed to make the string well-formed, each on a separate line.

Examples

Example 1

Loading
Loading