#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    int copen = 0, last = 0, m = 0, cclose = 0, flag = 0;
    stack<char> s1;
    if (s[i] != '?') s1.push(s[i]);
    if (s[i] == '?') {
      m = 1;
      flag = 1;
    } else if (s[i] == '(')
      copen++;
    else
      cclose++;
    for (int j = i + 1; j < s.size(); j++) {
      if (m == 0 && cclose > copen) break;
      if (s[j] == '(') {
        copen++;
        s1.push(s[j]);
      } else if (s[j] == ')') {
        if (!s1.empty() && s1.top() == '(') {
          copen--;
          s1.pop();
        } else if (m == 0) {
          if (last) {
            last--;
            m++;
          } else
            break;
        } else {
          m--;
        }
      } else {
        m++;
        if (copen - cclose > 0) {
          last++;
          m--;
          copen--;
          s1.pop();
        }
        flag = 1;
      }
      if (m % 2 == 0 && s1.empty()) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
