Here is a string: ({[{[]}]}). Your job is simple -- remove matching pairs until the string is empty, or declare it invalid. Go ahead, start tapping.
Find the innermost matching pair and tap to remove it. Then scan again. Five nesting levels means five passes.
How many passes will it take to reduce ({[{[]}]}) to empty, removing only adjacent matching pairs?