import java.util.Scanner;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str_brackets = sc.nextLine();
char[] brackets = str_brackets.toCharArray();
Stack<Integer> stack = new Stack<Integer>();
stack.push(-1);
int max_valid_len = 0;
for(int i = 0; i<brackets.length; i++) {
int temp = stack.peek();
if((temp!=-1) && (brackets[i]==')') && (brackets[temp]=='(')) {
stack.pop();
max_valid_len = Math.max(max_valid_len,i-stack.peek());
}else {
stack.push(i);
}
}
System.out.println(max_valid_len);
}
}