#include<bits/stdc++.h>
using namespace std;
stack<int> st;char a[10002];
int main(){
int k,u = 0,n,m,s = 0,r;
cin>>a;
for(int i = 0;i < strlen(a);i++){
if(st.empty()){
if(a[i] == ')')st.push(0);
else st.push(9);
continue;
}
if(a[i] == ')' && st.top() == 9)
st.pop();
else {
if(a[i] == ')')st.push(0);
else st.push(9);
}
}
cout<<st.size();
return 0;
}