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>.
#! python3
# longest regular bracket sequence

class Stack():
    def __init__(self, stack = None):
        if type(stack) is type([]):
            self.stack = stack
        elif stack is None:
            self.stack = []
        else:
            print('\nError Message:\n\tYour input is not type of list!\n\tPlease enter list type!\n')

    def get_length(self):
        return len(self.stack)

    def push(self, e):
        self.stack.append(e)
        return self.stack

    def pop(self):
        try:
            sEl = self.stack.pop()
            return (sEl, self.stack)
        except IndexError:
            print('\nError Message:\n\tThere is no element in the stack!\n')

    def clear(self):
        self.stack = []

sequence = input()

max_length = 0
max_length_num = 0

def max_length_update(current_length):
    global max_length, max_length_num
    if current_length == max_length:
        max_length_num += 1
    elif current_length > max_length:
        max_length = current_length
        max_length_num = 1

bracket_stack = Stack()
current_length = 0
for i in range(len(sequence)):
    if sequence[i] == '(':
        if bracket_stack.get_length() == 0:
            max_length_update(current_length)
            bracket_stack.push(i)
            current_length = 0
        else:
            bracket_stack.push(i)
    elif sequence[i] == ')':
        if bracket_stack.get_length() != 0:
            bracket_stack.pop()
            current_length += 2
    if i == len(sequence)-1:
        max_length_update(current_length)

if max_length == 0:
    print(0, 1)
else:
    print(max_length, max_length_num)
