#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[5005];
  scanf("%s", c);
  int cnt = 0;
  for (int i = 1; c[i] != 0; i++) {
    int Max = 0, Min = 0;
    for (int j = i; j >= 0; j--) {
      if (c[j] == ')')
        Max++, Min++;
      else if (c[j] == '(')
        Max--, Min--;
      else
        Max++, Min--;
      if (Max < 0) break;
      if (Min < 0) {
        Min = Max & 1;
      }
      if (Min == 0) cnt++;
    }
  }
  printf("%d\n", cnt);
}
