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>.
from sys import stdin


def input_data():
    for line in stdin:
        return line.strip()


def update_ans(ansCnt, ansLen, curLen):
    if curLen <= 0:
        return ansCnt, ansLen

    if curLen == ansLen:
        return ansCnt+1, ansLen
    elif curLen > ansLen:
        return 1, curLen

    return ansCnt, ansLen


def solve_prob(line):
    curSum, curLen = 0, 0
    ansCnt, ansLen = 1, 0

    for ch in line:
        if curSum < 0:
            if ch == '(':
                curSum, curLen = 1, 1
            else:
                curSum, curLen = -1, 0
        elif curSum == 0:
            ansCnt, ansLen = update_ans(ansCnt, ansLen, curLen)
            if ch == '(':
                curSum, curLen = curSum+1, curLen+1
            else:
                curSum, curLen = -1, 0
        else:
            if ch == '(':
                curSum, curLen = curSum+1, curLen+1
            else:
                curSum, curLen = curSum-1, curLen+1
    # final check
    if curSum == 0:
        ansCnt, ansLen = update_ans(ansCnt, ansLen, curLen)

    print(str(ansLen) + " " + str(ansCnt))


if __name__ == "__main__":
    line = input_data()
    solve_prob(line)
