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


class BracketsStack:
    def __init__(self):
        self.max_length = 0
        self.regular_seq_count = 0
        self.__last_reg_length = 0
        self.__brackets_stack = 0

    def add(self, bracket: str):
        if bracket == '(':
            self.__brackets_stack += 1
        elif bracket == ')':
            self.__brackets_stack -= 1

        if self.__brackets_stack < 0:
            if self.__last_reg_length:
                self.__add_new_seq()

            self.__last_reg_length = 0
            self.__brackets_stack = 0
        else:
            self.__last_reg_length += 1

    def get_result(self):
        if self.__brackets_stack == 0:
            self.__add_new_seq()
        return f'{self.max_length} {self.regular_seq_count  or 1}'

    def __add_new_seq(self):
        if self.__last_reg_length > self.max_length:
            self.max_length = self.__last_reg_length
        if self.__last_reg_length:
            self.regular_seq_count += 1


if __name__ == "__main__":
    bs = BracketsStack()
    line = next(sys.stdin)

    for s in line.strip():
        bs.add(s)

    print(bs.get_result())
