import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.next();
Stack<Integer> stack = new Stack();
int maxans = 0;
stack.push(-1);
for(int i = 0; i<s.length();i++){
if(s.charAt(i)=='('){
stack.push(i);
}else{
stack.pop();
if(stack.isEmpty()){
stack.push(i);
}else{
maxans = Math.max(maxans,i-stack.peek());
}
}
}
System.out.println(maxans);
}
}
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.next();
Stack<Integer> stack = new Stack();
int maxans = 0;
stack.push(-1);
for(int i = 0; i<s.length();i++){
if(s.charAt(i)=='('){
stack.push(i);
}else{
stack.pop();
if(stack.isEmpty()){
stack.push(i);
}else{
maxans = Math.max(maxans,i-stack.peek());
}
}
}
System.out.println(maxans);
}
}