#include <bits/stdc++.h>
using namespace std;
long long qp(long long a, long long b, long long mod) {
  long long t = 1;
  while (b) {
    if (b & 1) t = t * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return t;
}
struct DOT {
  int x;
  int y;
};
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {1, -1, 0, 0};
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int maxn = 5e3 + 7;
char s[maxn];
int main() {
  scanf("%s", s + 1);
  int len = strlen(s + 1);
  int ans = 0;
  for (int i = 1; i <= len; i++) {
    int cntl = 0, delta = 0;
    for (int j = i; j <= len; j++) {
      if (s[j] == '(')
        cntl++;
      else if (s[j] == '?') {
        if (cntl == delta) {
          cntl++;
        } else
          delta++;
      } else {
        if (cntl == delta)
          delta--;
        else
          cntl--;
        if (cntl < 0 || delta < 0) break;
      }
      if ((j - i + 1) % 2 == 0 && cntl == delta) ans++;
    }
  }
  printf("%d\n", ans);
}
