#include <bits/stdc++.h>
using namespace std;
int func(string s){
stack<char> brackets;
int n = s.size();
int ret = 0;
for(auto i = 0;i < n;++i){
if(s[i] == '(')
brackets.push(s[i]);
else {
/*考虑这样一种情况,s以)开头,这时候就不能出栈了,用一个变量记录缺少的(数量*/
if(brackets.empty())
++ret;
else
brackets.pop();
}
}
return ret + brackets.size();
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
string s;
cin >> s;
cout<<func(s)<<endl;
return 0;
}