#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[5004];
  scanf("%s", s);
  int cnt = 0;
  int n = strlen(s);
  int c = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == '?') c++;
  for (int i = 0; i < n; i++) {
    int open = 0;
    int close = 0;
    int quest = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == ')') close++;
      if (s[j] == '(') open++;
      if (s[j] == '?') {
        quest++;
        close++;
      }
      if (close == open) cnt++;
      if (close > open)
        if (quest > 0) {
          open++;
          close--;
          quest--;
        } else
          break;
    }
  }
  printf("%d", cnt);
  return 0;
}
