#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int curl = 0, curr = 0, ans = 0;
  bool bl, br;
  int b = 0, k = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == '(')
      b++;
    else {
      if (b > 0)
        b--;
      else
        continue;
      k++;
      ans = max(ans, k);
    }
  }
  cout << ans * 2;
  return 0;
}
