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()

bracket_sum=[]
valid_brackets=[0]
invalid_index=[]
max_length=0
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)
            bracket_sum[x]=-1000

    if 0 in bracket_sum :
        index=bracket_sum.index(0)
        length=len(bracket_sum)-index
        if length>=max_length:
            max_length=length
            valid_brackets.append(length)
    if bracket_sum[0]<0 :
        bracket_sum=[]
        invalid_index=[]
        i=-1
    i+=1
print(max_length,valid_brackets.count(max_length))
            
            
        
    
