//算法练习No.15
//栈的思想,但未必就要写std::stack<char>
//使用“虚拟栈”,将降低控件复杂度
#include <bits/stdc++.h>
using namespace std;

int solve(const string& s)
{
    int current_depth{0};
    int Max{0};
    for(char c : s)
    {
        if(c == '(')
        {
            current_depth++;
            Max = max(Max,current_depth);
        }
        else if(c == ')')
        {
            current_depth--;
        }
    }
    return Max;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    cout << solve(s) << endl;

    return 0;
}