#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << "\n";
  err(++it, args...);
}
const int MOD = 1e9 + 7, N = 5e3 + 5;
vector<vector<bool>> l(N, vector<bool>(N, false)), r(N, vector<bool>(N, false));
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  {
    string s;
    cin >> s;
    int n = ((int)(s).size());
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int a = 0, b = 0;
      for (int j = i; j < n; j++) {
        if (s[j] == '(')
          a++;
        else if (s[j] == ')')
          a--;
        else
          b++;
        while (b > a and b > 0) {
          a++;
          b--;
        }
        if (a < 0)
          break;
        else if ((j - i + 1) % 2 == 0 and b == a)
          ans++;
      }
    }
    cout << ans;
  }
}
