#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int sum1 = 0, sum2 = 0;
  string a;
  cin >> a;
  for (int i = 0; i < a.size(); i++)
    if (a[i] == '(')
      sum1++;
    else if (a[i] == ')' && sum1) {
      sum2++;
      sum1--;
    }
  cout << 2 * sum2;
}
