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>.
string=input()

n=len(string)
brackets=[]
bracket_sum=[]
valid_brackets=[0]
invalid_index=[]
i=0
for char in string:
    bracket_sum.append(0)
    
    if char=='(':
        bracket_sum=[j+1 for j in bracket_sum]
    else:
        bracket_sum=[j-1 for j in bracket_sum]
    #print(i,len(bracket_sum)-1)
    for x in range(len(bracket_sum)):
        if bracket_sum[x]<0:
            invalid_index.append(x)
    for ind in set(invalid_index):
        bracket_sum[ind]=-1
    if 0 in bracket_sum :
        index=bracket_sum.index(0)
        valid_brackets.append(len(bracket_sum)-index)
    if bracket_sum[0]<0 :
        bracket_sum=[]
        invalid_index=[]
        i=-1
    i+=1
m=max(valid_brackets)
if m==0:
    print(0,1)
else:
    print(m,valid_brackets.count(m))
            
            
        
    
