#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long N = 5000 + 5;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long n = s.length(), good = 0;
  for (long long i = 0; i < n; i++) {
    long long score = 0, qmarks = 0;
    for (long long j = i; j < n; j++) {
      if (s[j] == '(')
        score++;
      else if (s[j] == ')')
        score--;
      else
        qmarks++;
      while (qmarks > 0 && qmarks > score) {
        qmarks--, score++;
      }
      if (score < 0) break;
      if ((score + qmarks) & 1) continue;
      if (score == qmarks) {
        good++;
      }
    }
  }
  cout << good << endl;
  return 0;
}
