#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
bool cnt1[5001][5001], cnt2[5001][5001];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  memset(cnt1, 0, sizeof(cnt1));
  memset(cnt2, 0, sizeof(cnt2));
  long long n = s.size();
  for (long long i = 0; i < n; i++) {
    bool check = 1;
    long long sum = 0;
    for (long long j = i; j < n; j++) {
      sum += (s[j] == '(' || s[j] == '?' ? 1 : -1);
      if (sum < 0) check = 0;
      cnt1[i][j] = check;
    }
    check = 1;
    sum = 0;
    for (long long j = i; j >= 0; j--) {
      sum += (s[j] == ')' || s[j] == '?' ? 1 : -1);
      if (sum < 0) check = 0;
      cnt2[j][i] = check;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      if ((j - i + 1) % 2 == 1 || !cnt1[i][j] || !cnt2[i][j])
        continue;
      else
        ans++;
    }
  }
  cout << ans << "\n";
}
