#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const long long LLINF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e2 + 10;
const int maxm = 1e5 + 10;
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    int mi = 0, ma = 0;
    for (int j = i; j < s.size(); j++) {
      if (s[j] == ')') {
        mi--;
        ma--;
      } else if (s[j] == '(') {
        mi++;
        ma++;
      } else if (s[j] == '?') {
        mi--;
        ma++;
      }
      if (ma < 0) break;
      if (mi < 0) mi += 2;
      if (mi == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
