#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
const int N = 5e3 + 10;
char s[N];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    int L = 0, R = 0;
    for (int j = i; j < n && L <= R; ++j) {
      if (s[j] == '(') {
        ++L;
        ++R;
      } else if (s[j] == ')') {
        --L;
        --R;
      } else {
        --L;
        ++R;
      }
      if (L < 0) L += 2;
      if (L == 0) {
        ++ret;
      }
    }
  }
  printf("%d\n", ret);
  return 0;
}
