#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=native")
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 2e5 + 5;
const int MAX = 2e6 + 5;
const int MOD = 1000000007;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(time(NULL));
  cout << fixed << setprecision(10);
  clock_t clk;
  clk = clock();
  ;
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  for (int l = 0; l < n; l++) {
    int lftcnt = 0, quecnt = 0;
    for (int r = l; r < n; r++) {
      if (s[r] == '(')
        lftcnt++;
      else if (s[r] == ')')
        lftcnt--;
      else
        quecnt++;
      if (lftcnt < 0) break;
      if (quecnt > lftcnt) quecnt--, lftcnt++;
      if ((r - l) & 1 && quecnt == lftcnt) ans++;
    }
  }
  cout << ans << "\n";
  clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk) / CLOCKS_PER_SEC
       << "\n";
  return 0;
  ;
}
