#include <bits/stdc++.h>
using namespace std;
int main() {
  int count = 0;
  string brackets;
  stack<char> st;
  cin >> brackets;
  for (int i = 0; i < brackets.length(); ++i) {
    if (brackets[i] == '(')
      st.push('(');
    else if (!st.empty()) {
      ++count;
      st.pop();
    }
  }
  printf("%d\n", count * 2);
  return 0;
}
