#include <bits/stdc++.h>
using namespace std;
int main() {
  string input;
  cin >> input;
  int basteha = 0;
  int bazha = 0;
  int ziad = 0;
  for (int i = 0; i < input.length(); i++) {
    if (input[i] == '(')
      bazha++;
    else
      basteha++;
    if (input[i] == ')') {
      if (bazha >= basteha)
        ziad = max(ziad, basteha);
      else {
        basteha--;
      }
    }
  }
  cout << ziad * 2 << endl;
  return 0;
}
