#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  string s;
  cin >> s;
  n = s.length();
  bool a[n][n];
  memset(a, false, sizeof(a));
  for (long long int i = 0; i < n; i++) {
    long long int o = 0, c = 0, m = 0;
    for (long long int j = i; j <= n - 1; j++) {
      if (s[j] == '(')
        o++;
      else if (s[j] == ')')
        c++;
      else
        m++;
      if (o + m >= c)
        a[i][j] = true;
      else
        break;
    }
  }
  long long int res = 0;
  for (int i = n - 1; i >= 0; i--) {
    long long int o = 0, c = 0, m = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == '(')
        o++;
      else if (s[j] == ')')
        c++;
      else
        m++;
      if (c + m < o) break;
      if (a[j][i] && ((i - j + 1) % 2 == 0) && (c + m >= o)) {
        res++;
      }
    }
  }
  cout << res;
  return 0;
}
