LearnPy Hub
← Arena
AdvancedRating 1500

Fewest Inserts to Balance

The string has (, ), [ and ]. Print the fewest bracket characters to insert anywhere so that it becomes properly balanced and nested.

Input

One string (length ≤ 100).

Output

One integer.

Sample 1

Input
([)]
Output
2

Sample 2

Input
((
Output
2
solution.py
Output appears here
Fewest Inserts to Balance · Python Arena problem · LearnPy Hub