Yeah, that's the first solution that popped in my mind too. I think it needs just a special case at the beginning to check if the first paren is not a closing one.
EDIT: yep, after reading the comments below I see that I really should have put just a little more thought before dismissing this as too trivial to think about.