#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long powe(long long x, long long y) {
  x = x % mod, y = y % (mod - 1);
  long long ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans = (1ll * x * ans) % mod;
    }
    y >>= 1;
    x = (1ll * x * x) % mod;
  }
  return ans;
}
void fun() {}
int idhar[5000][5000];
int udhar[5000][5000];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  fun();
  string s;
  cin >> s;
  int n = s.length();
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int aise = 0, vaise = 0, jaise = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == '(')
        aise++;
      else if (s[j] == ')')
        vaise++;
      else
        jaise++;
      if (vaise > aise + jaise) {
        break;
      }
      idhar[i][j] = 1;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    int aise = 0, vaise = 0, jaise = 0;
    for (int j = i; j >= 0; j--) {
      if (s[j] == '(')
        aise++;
      else if (s[j] == ')')
        vaise++;
      else
        jaise++;
      if (aise > vaise + jaise) {
        break;
      }
      udhar[j][i] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if ((j - i) % 2 != 0 && idhar[i][j] && udhar[i][j]) cnt++;
    }
  }
  cout << cnt << "\n";
}
