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
def input(): return sys.stdin.readline().strip()

stri = input()
S = [];j=0
for i in stri:
    S.append((i,j))
    j+=1
stack = [];count = 1;maxi = 0;l=0
for i,j in S:
    if len(stack) == 0:
        stack.append((i,j))
    elif i == "(":
        stack.append((i,j))
    else:
        if stack[-1][0] == "(":
            x = stack.pop()
            l = j - x[1] + 1
            if l>maxi:
                maxi = l
                count=1
            elif l == maxi:
                count+=1
        else:
            stack.append((i,j))
print(maxi,count)