/**
bit2014_3 2018-8-15 16:28
求广义表的深度, (c,((d,e),f),h) (c,((d,(a,b),e),f),(h,h),h)
输出 3
思路:本题我才用了匹配括号的方法,当遇到 ) 时 countl++;
当遇到 ( 时 检查 countl是否为0 若是 则 countr++ 否则 countl-- countr不变
最后countr就是最终结果,
**/
#include<iostream>
#include<string.h>
using namespace std;
int main(){
char gene[100];
cin>>gene;
int countr=0,countl=0;
for(int i=0;i<strlen(gene);i++){
if(gene[i]=='('){
if(countl>0){
countl--;
}else{
countr++;
}
}
if(gene[i]==')') countl++;
}
cout<<countr;
return 0;
}