#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:667177216")
const long long mod = 1000000007;
const int maxn = 5010;
bool pref[maxn][maxn], suf[maxn][maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    bool check = true;
    for (int j = i; j < n; j++) {
      if (s[j] == ')')
        tmp--;
      else
        tmp++;
      if (tmp < 0) check = false;
      pref[i][j] = check;
    }
  }
  for (int i = 0; i < n; i++) {
    int tmp = 0;
    bool check = true;
    for (int j = i; j >= 0; j--) {
      if (s[j] == '(')
        tmp--;
      else
        tmp++;
      if (tmp < 0) check = false;
      suf[i][j] = check;
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (pref[i][j] && suf[j][i] && (j - i + 1) % 2 == 0) res++;
    }
  }
  cout << res << '\n';
  return 0;
}
