#include <bits/stdc++.h>
using namespace std;
int n;
string s;
bool valid(int a, int b, int c) {
  int sum = a + b + c;
  if (sum & 1) return false;
  return a + c >= b && b + c >= a;
}
bool con(int a, int b, int c) { return a + c >= b; }
int solve() {
  int res = 0;
  for (int i = 0, _n = (n); i < _n; i++) {
    int a = 0, b = 0, c = 0;
    for (int j = (i), _b = (n - 1); j <= _b; j++) {
      if (s[j] == ')') {
        b++;
        if (a < c + b) {
          if (c) {
            a++;
            c--;
          } else
            break;
        }
      } else if (s[j] == '(') {
        a++;
      } else if (s[j] == '?') {
        c++;
        if (a < c + b) {
          a++;
          c--;
        }
      }
      if (s[j] == ')') {
        if (valid(a, b, c)) res++;
      } else if (s[j] == '?') {
        if (c && valid(a, b + 1, c - 1))
          res++;
        else if (!c && valid(a, b, c))
          res++;
      }
    }
  }
  return res;
}
int main() {
  cin >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}
