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>.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" " ;
#define pb(x) push_back(x)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=2e5+5;
stack<int>stk;
map<int,int>mp;
int main()
{
	string s;
	cin>>s;
	int len,mx;
	len=mx=0;
	rep(i,0,s.size()){
	
		if(len){
			
			mx=max(len,mx);
			mp[len]++;
		}
		if(s[i]=='(')stk.push(1);
		else if(s[i]==')'){
			if(!stk.empty()&&stk.top()==1){
				stk.pop();
				len+=2;
			}
			else len=0;
		}
	}
	if(len){
		mx=max(len,mx);
		mp[len]++;
	}
	mp[0]=1;
	cout<<mx<<" "<<mp[mx]<<endl;
	
	return 0;
}
