Problem: 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.

Input

The first line of the input file contains a non-empty string, consisting of «(» and «)» characters. Its length does not exceed 106.

Output

Print the length of the longest substring that is a regular bracket sequence, and the number of such substrings. If there are no such substrings, write the only line containing "0 1".

Examples

Input

)((())))(()())


Output

6 2


Input

))(


Output

0 1

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;


public class LongestBracketSequence
{
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int curr = 0;
		int st=-1, en=-1;
		ArrayList<Pair> res = new ArrayList<Pair>();
		for (int i = 0; i < arr.length; i++)
		{
			if(arr[i] == '(')
			{
				if(curr == -1)
					curr = 0;
				if(curr == 0)
					st = i;
				curr++;
			}
			if(arr[i] == ')')
			{
				curr = Math.max(-1, curr-1);
				if(curr == 0)
				{
					en = i;
					res.add(new Pair(st, en, en-st+1));
				}
			}
		}
		
		curr = 0;
		for (int i = arr.length-1; i >= 0; i--)
		{
			if(arr[i] == ')')
			{
				if(curr == -1)
					curr = 0;
				if(curr == 0)
					en = i;
				curr++;
			}
			if(arr[i] == '(')
			{
				curr = Math.max(curr-1, -1);
				if(curr==0)
				{
					st = i;
					Pair p = new Pair(st, en, en-st+1);
					res.add(p);
				}
			}
		}
		Collections.sort(res);
		int cnt = 0;
		int longest = 0;
		for (int i = 0; i < res.size()-1; i++)
		{
			if(res.get(i).y == res.get(i+1).x - 1)
			{
				int num = res.get(i).len + res.get(i+1).len;
				if(num > longest)
				{
					longest = num;
					cnt = 1;
				}
				else
					if(num == longest)
					{
						cnt++;
					}
				res.set(i+1, new Pair(res.get(i+1).x, res.get(i+1).y, res.get(i).len + res.get(i+1).len));
			}
			else
			{
				if(res.get(i).compareTo(res.get(i+1))==0 && i!=res.size()-2)
				{
					res.set(i+1, res.get(i));
				}
				else
				{
					int num = res.get(i).y - res.get(i).x + 1;
					if(num > longest)
					{
						longest = num;
						cnt = 1;
					}
					else
						if(num == longest)
							cnt++;
				}
			}
		}
		if(res.size() > 0)
		{
			if(res.size()>1 && res.get(res.size()-1).compareTo(res.get(res.size()-2)) == 0)
				;
			else
			{
				int num = res.get(res.size()-1).y - res.get(res.size()-1).x + 1;
				if(num > longest)
				{
					cnt =1;
					longest = num;
				}
				else
					if(num == longest)
					{
						cnt++;
					}
			}
		}
		if(longest == 0)
			System.out.println("0 1");
		else
			System.out.println(longest + " " + cnt);
	}
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}
	}
	
	
	static class Pair implements Comparable<Pair>
	{
		int x, y, len;
		public Pair(int x, int y, int l)
		{
			this.x = x;
			this.y = y;
			len = l;
		}
		
		public int compareTo(Pair p)
		{
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
		public String toString()
		{
			return x + " " + y + " " + len;
		}
	}
}