Regular bracket sequence 2 - MarisaOJ: Marisa Online Judge

Regular bracket sequence 2

Time limit: 1000 ms
Memory limit: 256 MB
The problem is asking for the minimum number of parentheses that need to be added to make a given sequence of parentheses valid. The sequence contains four types of characters: `(`, `)`, `[`, and `]`. Definition of a valid parentheses sequence: - An empty string is a valid parentheses sequence. - If A is a valid parentheses sequence, then `(A)` and `[A]` are also valid parentheses sequences. - If A and B are valid parentheses sequences, then AB is also a valid parentheses sequence. ### Input - One line containing a string S. ### Output - Print an integer representing the minimum number of parentheses to be added. ### Constraints - $1 \le |S| \le 100$. ### Sample test Input: ``` []) ``` Output: ``` 1 ```