#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int N = s.size();
  int res = 0;
  for (int lft = 0; lft < N; lft++) {
    int lo = 0;
    int hi = 0;
    for (int len = 1; len < (N - lft + 1); len++) {
      if (s[lft + len - 1] == ')') {
        hi--;
        lo--;
        if (hi < 0) break;
        if (lo < 0) lo = 0;
      } else if (s[lft + len - 1] == '(') {
        hi++;
        lo++;
      } else {
        hi++;
        lo--;
        if (lo < 0) lo = 0;
      }
      if (lo == 0) {
        if (len % 2 == 0) {
          res++;
        }
      }
    }
  }
  cout << res << endl;
}
