Deepest nesting

Write max_depth(text) that returns how deeply the round brackets in text nest. Unbalanced text returns -1. Other characters are ignored.

max_depth("(a(b)(c(d)))")  ->  3
max_depth("()")            ->  1
max_depth("")              ->  0
max_depth("(()")           ->  -1
def max_depth(text):
    ...