#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long open = 0, close = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '(') {
      open++;
    } else
      close++;
    if (close > open) {
      close = open;
    }
  }
  if (open > close) {
    open = close;
  }
  cout << open + close;
  return 0;
}
