#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline T read() {
  register T sum(0), fg(1);
  register char ch(getchar());
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fg = -1;
  for (; isdigit(ch); ch = getchar()) sum = sum * 10 + ch - '0';
  return sum * fg;
}
const int MAXN = int(5e3);
int n;
char s[MAXN + 5];
inline void input() { scanf("%s", s), n = strlen(s); }
int ans = 0;
inline void calc(int st) {
  int cnt0 = 0, cnt1 = 0, cnt2 = 0;
  for (int i = st; i < n; ++i) {
    if (s[i] == '?') {
      ++cnt1;
      cnt2 = min(cnt2 + 1, min(cnt0, cnt1));
    }
    if (s[i] == '(') ++cnt0;
    if (s[i] == ')') {
      if (cnt0)
        --cnt0, chkmin(cnt2, cnt0);
      else {
        if (cnt1)
          --cnt1, chkmin(cnt2, cnt1);
        else
          break;
      }
    }
    if (cnt2 >= cnt0) ans += !((cnt0 - cnt1) & 1);
  }
}
inline void solve() {
  for (int i = 0; i < n; ++i) calc(i);
  printf("%d\n", ans);
}
int main() {
  input();
  solve();
  return 0;
}
