Long Parenthesis

easy
1. Given a string S consisting of opening and closing parenthesis '(' and ')'. 
  2. Find length of the longest valid parenthesis substring.

Input Format

First line- An integer 'N' Second line- string S of character '(' and ')' of length N.

Output Format

An integer

Constraints

1 <= T <= 500
  1 <= N <= 105

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
)()())
Output
4
Previous
Finding Smaller Towards Left And Right
Next
Maximum Of Min Numbers In K Sized Subarrays

Related Questions