#include<bits/stdc++.h>
using namespace std;
stack s;
int main(){
string t;
getline(cin,t);
int len=t.length();
//cout<<"pusha: "<<t[0]<<endl;
for(int i=0;i<len;++i){
if(s.empty() ){
if(t[i]=='(' || t[i]==')'){
s.push(t[i]);
//cout<<"pusha: "<<t[i]<<endl;
}
continue;
}
char nz=s.top();
if(t[i]=='(' ){
s.push(t[i]);
//cout<<"pushb: "<<t[i]<<endl;
}
else if(t[i]==')'){
if(nz=='('){
s.pop();
//cout<<"popa: "<<nz<<endl;
}
else if(nz==')'){
s.push(t[i]);//cout<<"pushc: "<<t[i]<<endl;
}
}
}
cout<<s.size();
}
_ ~~**