#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read_to_vector(size_t N, std::vector<T> &v) {
  for (size_t i = 0; i < N; i++) {
    T tmp;
    std::cin >> tmp;
    v.push_back(tmp);
  }
}
template <typename T>
void print_vector(const std::vector<T> &v) {
  for (auto it = v.begin(); it < v.end(); it++) {
    if (it != v.begin()) std::cout << " ";
    std::cout << (*it);
  }
}
void solve() {
  string s;
  cin >> s;
  vector<long long> a;
  vector<long long> b;
  vector<long long> q;
  a.push_back(0);
  b.push_back(0);
  q.push_back(0);
  long long aa = 0;
  long long bb = 0;
  long long qq = 0;
  for (auto c : s) {
    if (c == '(') {
      aa++;
    }
    if (c == ')') {
      bb++;
    }
    if (c == '?') {
      qq++;
    }
    a.push_back(aa);
    b.push_back(bb);
    q.push_back(qq);
  }
  long long res = 0;
  for (long long i = 0; i < s.size(); i++) {
    long long aa = 0;
    long long bb = 0;
    for (long long j = i; j < s.size(); j++) {
      char &c = s[j];
      if (c == '(') {
        aa++;
        bb++;
      }
      if (c == ')') {
        aa--;
        bb--;
      }
      if (c == '?') {
        aa--;
        bb++;
      }
      if (aa < 0) {
        aa += 2;
      }
      if (aa > bb) {
        break;
      }
      if (aa == 0) {
        res++;
      }
    }
  }
  cout << res << endl;
}
void pre_compute() {}
int main() {
  std::cout << std::setprecision(15);
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  pre_compute();
  solve();
  return 0;
}
