#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
const long long M = 1e9 + 7;
char s[N];
signed main() {
  scanf("%s", s + 1);
  long long n = strlen(s + 1), sq = 0;
  for (long long i = 1; i <= n; ++i) {
    long long mx = 0, su = 0;
    for (long long j = i; j <= n; ++j) {
      if (s[j] == '(')
        mx++;
      else if (s[j] == ')')
        mx--;
      else {
        if (mx > 0)
          su++, mx--;
        else
          mx++;
      }
      if (mx < 0) {
        if (su == 0) break;
        mx += 2;
        su--;
      }
      if (mx == 0) sq++;
    }
  }
  cout << sq << "\n";
}
