#include <bits/stdc++.h>
using namespace std;
char s[5010], sta[5010];
int l, ans, top, sum, extra;
inline void check(int x) {
  top = 0;
  sum = 0;
  extra = 0;
  for (int i = x; i < l; i++) {
    if (s[i] == '?') {
      sum++;
      if (extra) extra--;
    } else if (s[i] == '(')
      sta[++top] = s[i], extra++;
    else {
      if (top && sta[top] == '(') {
        top--;
        if (extra) extra--;
      } else if (sum)
        sum--;
      else
        return;
    }
    if ((!top && sum % 2 == 0) || (top == sum && !extra) ||
        (sum > top) && (sum - top) % 2 == 0 && !extra) {
      ans++;
    }
  }
  return;
}
int main() {
  scanf("%s", s);
  l = strlen(s);
  sta[0] = '@';
  for (int i = 0; i < l; i++) {
    check(i);
  }
  printf("%d\n", ans);
}
