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>.
if __name__ == '__main__':
	para = input('')	
	i = 0
	max_len = 0
	counter = 0
	while i < len(para):
		x = 0
		j = i
		length = 0
		started = False
		valid_len = 0
		while j < len(para):
			#print(para[j])
			if para[j] == '(':
				x += 1
				length += 1
				started = True
			if para[j] == ')':
				x -= 1
				length += 1
			if x < 0:
				#print('breaking')
				break
			if x == 0 and started == True:
				if length > valid_len:
					valid_len = length
				#print('valid_len', valid_len)
			j += 1
		if valid_len > max_len:
			max_len = valid_len
			#print('max_len', max_len)
			
		if valid_len != 0:
			counter += 1
			#print('counter', counter)
			i = i + valid_len
		else:
			i += 1
	if counter == 0: 
		counter = 1
	print(max_len, counter)