#include <bits/stdc++.h>
using namespace std;
template <class T>
void checkmin(T& a, T b) {
  if (a > b) a = b;
}
template <class T>
void checkmax(T& a, T b) {
  if (a < b) a = b;
}
template <class T>
void gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const double EPS = (1e-10);
const int INF = (1 << 29);
const long long LINF = (1LL << 60);
const int MAXN = 1000000 + 10;
char brack[MAXN];
int main() {
  scanf("%s", brack);
  int left = 0, right = 0;
  int ret = 0;
  for (int i = 0; brack[i]; i++) {
    if (brack[i] == '(')
      left++;
    else
      right++;
    if (left < right) right = left;
    checkmax(ret, min(left, right) * 2);
  }
  cout << ret << endl;
}
