import java.util.Scanner;
import java.util.Stack;
public class Main {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
while(scan.hasNext()){
String s=scan.next();
System.out.println(result(s));
}
scan.close();
}
private static int result(String s) {
if(s==null||s.equals("")){
return 0;
}
Stack<Character> stack=new Stack<Character>();
int len=s.length();
int i=0;
int max=1;
while(i<len){
if(s.charAt(i)=='('){
stack.add('(');
max=max>stack.size()?max:stack.size();
}else{
stack.pop();
}
i++;
}
return max;
}
}