#include <bits/stdc++.h>
using namespace std;
template <class T>
T input_value(istream& input = cin) {
  T value;
  input >> value;
  return value;
}
template <typename T1, typename T2>
void print_iterable(T1 begin_iter, T2 end_iter) {
  cerr << "[";
  for (; begin_iter != end_iter; ++begin_iter) {
    cerr << *begin_iter << ", ";
  }
  cerr << "]\n";
}
int const MAXN = 5002;
string s;
int minimum[MAXN][MAXN];
int maximum[MAXN][MAXN];
int n;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  n = s.length();
  int sol = 0;
  for (int j = 0; j <= n; ++j) {
    for (int i = 0; i <= j; ++i) {
      if (i == j) {
        minimum[i][j] = 0;
        maximum[i][j] = 0;
      } else {
        int a = minimum[i][j - 1];
        int b = maximum[i][j - 1];
        char c = s[j - 1];
        if (c == ')') {
          minimum[i][j] = max(a - 1, (j - i) % 2);
          maximum[i][j] = max(b - 1, -1);
        }
        if (c == '(') {
          minimum[i][j] = a + 1;
          maximum[i][j] = (b >= 0) ? b + 1 : -1;
        }
        if (c == '?') {
          minimum[i][j] = max(a - 1, (j - i) % 2);
          maximum[i][j] = (b >= 0) ? b + 1 : -1;
        }
        if (minimum[i][j] == 0 && maximum[i][j] >= 0) ++sol;
      }
    }
  }
  cout << sol << "\n";
  return 0;
}
