#include <bits/stdc++.h>
using namespace std;
string s;
int str = 0;
short dp[5005][5005];
bool go(short i, short j) {
  if (i > j) return 1;
  if (i == j) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  bool ret = 0;
  bool tmp = go(i + 1, j - 1);
  if (s[i] != ')' && s[j] != '(' && tmp) ret = 1;
  for (short k = i; k < j; k++) {
    tmp = go(i, k);
    if (go(k + 1, j) && tmp) ret = 1;
  }
  if (ret) {
    str++;
  }
  return dp[i][j] = ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  int n = s.size();
  int res = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0, o = 0, c = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == ')')
        cnt--;
      else if (s[j] == '(')
        cnt++;
      else {
        if (cnt > 0)
          cnt--, c++;
        else
          cnt++, o++;
      }
      while (c && cnt < 0) o++, c--, cnt += 2;
      if (!cnt) {
        res++;
      }
      if (cnt < 0) break;
    }
  }
  cout << res << endl;
  return 0;
}
