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 get_result(string):
    brackets = [0] * len(string)
    stack = []
    for i, s in enumerate(string):
        if s == '(':
            stack.append(i)
        else:
            if stack:
                brackets[stack.pop()] = 1
                brackets[i] = 1
    max_len = 0
    count = 0
    cur_chain = 0

    for i, bracket in enumerate(brackets):
        if not bracket and cur_chain:
            if cur_chain > max_len:
                max_len = cur_chain
                count = 1
            elif cur_chain == max_len:
                count += 1

            cur_chain = 0
        else:
            cur_chain += bracket

    if cur_chain > max_len:
        return cur_chain, 1
    elif cur_chain == max_len:
        count += 1
    return max_len, count


if __name__ == "__main__":
    import sys

    line = next(sys.stdin).strip()

    max_len, count = get_result(line)[:2]
    print(f'{max_len} {count or 1}')
