#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  stack<char> in;
  int c = 0;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    switch (s[i]) {
      case '(':
        in.push(s[i]);
        break;
      case ')':
        if (in.empty()) {
          break;
        }
        in.pop();
        c++;
        break;
      default:
        break;
    }
    if (ans < c) {
      ans = c;
    }
  }
  cout << c * 2 << endl;
  return 0;
}
