Given a string s of '(' and ')', return the number of matched parenthesis pairs — each ')' that has an available unmatched '(' before it forms one pair. Unmatched characters are ignored. The input is JSON {s}.
Input: JSON {s}.
Output: Integer — the number of matched pairs.
Input: {"s":"(())"}
Output: 2
Explanation: Two nested pairs.Input: {"s":"(()"}
Output: 1
Explanation: One pair matches; an open is unmatched.Input: {"s":")("}
Output: 0
Explanation: No valid pair.0<=|s|<=10^5