#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  int fans = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == ')') continue;
    int cnt1 = 0;
    int cnt2 = 0;
    for (int j = i; j < s.length(); j++) {
      if (s[j] == '(') {
        cnt1++;
        continue;
      } else if (s[j] == ')') {
        if (cnt1 + cnt2 == 0) {
          break;
        }
        if (cnt1 == 0) {
          cnt2--;
        } else {
          cnt1--;
        }
        if (cnt1 > cnt2) continue;
      } else {
        if (cnt1 == 0) {
          cnt1++;
          continue;
        } else {
          cnt2++;
          if (cnt1 > cnt2) continue;
        }
      }
      while (cnt1 < cnt2) {
        cnt1++;
        cnt2--;
      }
      if (cnt1 % 2 == cnt2 % 2 && cnt1 <= cnt2) {
        fans++;
      }
    }
  }
  cout << fans << endl;
  return 0;
}
