#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int res = 0, cur_open = 0;
  for (char c : s) {
    if (c == '(') {
      cur_open++;
    } else {
      if (cur_open > 0) {
        cur_open--;
      } else {
        res++;
      }
    }
  }
  res += cur_open;
  cout << res << endl;
  return 0;
}
