#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5010;
long long f[maxn][maxn];
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  long long n = (long long)s.size();
  for (long long i = 0; i < (n); ++i) {
    long long cnt = 0;
    for (long long j = i; j < n; ++j) {
      if (s[j] == ')')
        cnt--;
      else
        cnt++;
      if (cnt >= 0)
        f[i][j]++;
      else
        break;
    }
  }
  for (long long i = n - 1; i >= 0; i--) {
    long long cnt = 0;
    for (long long j = i; j >= 0; --j) {
      if (s[j] == '(')
        cnt--;
      else
        cnt++;
      if (cnt >= 0)
        f[j][i]++;
      else
        break;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < (n); ++i) {
    for (long long j = i; j <= n; ++j) {
      if ((j - i + 1) % 2 == 0 and f[i][j] == 2) ans++;
    }
  }
  cout << ans << '\n';
}
