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

# Input reading function aliases
si = lambda : int(sys.stdin.readline())
sii = lambda : map(int, sys.stdin.readline().split())
siii = lambda : map(int, sys.stdin.readline().split())
sl = lambda : int(sys.stdin.readline())
sll = lambda : map(int, sys.stdin.readline().split())
slll = lambda : map(int, sys.stdin.readline().split())

# Utility function aliases
cel = lambda n, k : (n - 1) // k + 1
sets = lambda a : memset(a, -1, sizeof(a))
clr = lambda a : memset(a, 0, sizeof(a))
fr = lambda n : [0 for i in range(n)]
fr1 = lambda n : [0 for i in range(1, n+1)]
pb = lambda v, x : v.append(x)
all = lambda v : v
mp = lambda x, y : (x, y)
INF = 10000007
fastIO = lambda : (sys.stdin.readline().strip())

n, m, len = 0, 0, 0
s = sys.stdin.readline().strip()
n = len(s)
d = [-1] * n
st = []

maxi, cnt = 0, 1

for i in range(n):
    if not st 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)
