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>.
def deleteStart():
    global s
    for i in range(0,len(s)): 
        if s[i] == '(': 
            s = s[i:]
            break
s = input()
subs = []
openedOverClosed = [0]
deleteStart()
i=0
lenn = 0
maxx = 0
while(1):
    if s[i] == '(':
        openedOverClosed.append(openedOverClosed[len(openedOverClosed)-1]+1)
        i+=1
    else:
        openedOverClosed.append(openedOverClosed[len(openedOverClosed)-1]-1)
        if openedOverClosed[len(openedOverClosed)-1] == 0:
            maxx = max(maxx,len(openedOverClosed)-1)
            lenn+=1
            s = s[len(openedOverClosed)+1:]
            deleteStart()
            i=0
            openedOverClosed = [0]
    if len(s)<2:
        break
if lenn ==0:
    print(0,1)
else:
    print(maxx,lenn)