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>.
str1 = input()
len1 = 0
maxlen = 0
stack = []
for i in str1:
    if i == ")":
        #print(len(stack))
        if len(stack) > 0 and stack[len(stack) - 1] == "(":
            stack.pop()
            len1 += 2
            if len(stack) == 0:
                maxlen = max(maxlen, len1)
                len1 = 0
    else:
        stack.append(i)
count = 0
stack = []
for i in str1:
    if i == ")":
        if len(stack) > 0 and stack[-1] == "(":
            stack.pop()
            len1 += 2
            if len(stack) == 0:
                if len1 == maxlen:
                    count += 1
                len1 = 0
    else:
        stack.append(i)
if maxlen > 0:
    print(maxlen, count)
else:
    print(0, 1)
