Sakib and Shamim are good friends. As Sakib is a little naughty, every night before exam he disturbs Shamim. One day Shamim got an idea to get rid of Sakib. Shamim gave him a sequence of parenthesis and bracket and told him to determine the maximum length of a valid sequence.
For example,  , () are valid sequence but (] [)(] are not. Remember an empty sequence is also a valid sequence. Since Sakib was intelligent he solved the problem easily and continued disturbing Shamim. Can you solve it too?
You will be given L (the length of the sequence) where L<=10^6 and the sequence will contain at least one character. You have to print the maximum length of a valid sequence.