#include<iostream>
using namespace std;
#include<stack>
int fenzhi(string s,int left,int right)
{
    if(left>right)return 0;
    int cnt=0;
    int res=0;
    int start=left;
    for(int i=left;i<=right;i++)
    {
        if(s[i]=='(')cnt++;
        else cnt--;
        if(cnt==0)
        {
            res=max(res,1+fenzhi(s,start+1,i-1));
            start=i+1;
        }
    }
    return res;
}
void test()
{
    string s;
    cin>>s;
    cout<<fenzhi(s,0,s.size()-1);
    
}
int main()
{
    test();
    return 0;
}