This is yet another problem dealing with regular bracket sequences.

We should remind you that a bracket sequence is called regular, if by inserting «+» and «1» into it we can get a correct mathematical expression. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are not. 

You are given a string of «(» and «)» characters. You are to find its longest substring that is a regular bracket sequence. You are to find the number of such substrings as well.
The first line of the input file contains a non-empty string, consisting of «(» and «)» characters. Its length does not exceed 10<sup class="upper-index">6</sup>.
import sys
from collections import defaultdict
from math import ceil

# input-output methods
si = lambda: int(input())
sii = lambda: map(int, input().split())
siii = lambda: map(int, input().split())
sl = lambda: int(input())
sll = lambda: map(int, input().split())
slll = lambda: map(int, input().split())
fastIO = lambda: sys.stdin.readline().rstrip()

# utility methods
def sets(a):
    for i in range(len(a)):
        a[i] = -1

def clr(a):
    for i in range(len(a)):
        a[i] = 0

def max(a, b):
    return a if a > b else b

def min(a, b):
    return a if a < b else b

# main logic
n, m, len = 0, 0, 0
s = list(fastIO())
d = [-1] * len(s)
st = []

maxi, cnt = 0, 1

for i in range(len(s)):
    if len(st) == 0 or s[i] == '(':
        st.append(i)
        continue

    pos = st[-1]

    if s[pos] == '(':
        if d[pos - 1] != -1:
            d[i] = d[pos - 1]
        else:
            d[i] = pos

        len = i - d[i] + 1
        if len == maxi:
            cnt += 1
        elif len > maxi:
            maxi = len
            cnt = 1

        st.pop()

print(maxi, cnt)

		  		      	 	 			 			  						