#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  long long int count = 0;
  int n = s.length();
  int ca = 0, cb = 0, cc = 0, co = 0;
  for (int i = 0; i < n; i++) {
    ca = 0;
    cb = 0;
    cc = 0;
    co = 0;
    for (int j = i; j < n; j++) {
      if (ca + cc < cb) {
        break;
      }
      if (co < 0) {
        co = 0;
      }
      if (cb == ca && cc > 0) {
        cc--;
        ca++;
      }
      if (s[j] == '(') {
        co++;
        ca++;
        continue;
      } else if (s[j] == ')') {
        cb++;
        co--;
      } else {
        if (ca == cb && cc == 0) {
          co += 2;
          ca++;
          cc--;
        }
        cc++;
        co--;
      }
      if (ca + cc == cb || (cb + cc == ca && co <= 0) ||
          ((j - i) % 2 == 1 && ca <= cc + cb && ca + cc >= cb && co <= 0)) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
