A regular brackets sequence is defined as follows.
For example, all of the following are regular brackets sequences:
(), [], (()), ([]), ()[], ()[()]
None of the following are regular brackets sequences:
(, [, ), )(, ([)], ([(]
You are given a string consisting of the four characters (, ), [, and ]. Among all regular brackets sequences that contain the given string as a subsequence, find the shortest one and report its length.
Here, a string a1a2…an is a subsequence of a string b1b2…bm if there exist indices 1≤i1<i2<⋯<in≤m such that aj=bij for every 1≤j≤n.
The first line contains a string made up only of the characters (, ), [, and ]. The string has length at most 100 and contains no other characters. The string may be empty (an empty line), which represents the empty sequence.
Print a single integer: the length of the shortest regular brackets sequence that contains the given string as a subsequence.