#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  int ans = 0;
  int mins, maxs;
  for (int i = 0; i < s.size(); i++) {
    mins = maxs = 0;
    for (int j = i; j < s.size(); j++) {
      if (s[j] == '(')
        mins++, maxs++;
      else if (s[j] == ')')
        mins--, maxs--;
      else
        mins--, maxs++;
      if (mins < 0) mins = 0;
      if (maxs < 0) break;
      if ((j - i + 1) % 2 == 0 && mins <= 0 && maxs >= 0) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
