#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int f[maxn][maxn][2], n, ans;
char s[maxn];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    f[i - 1][0][0]++;
    for (int j = 0; j <= i; j++) {
      if (s[i] == ')' && j >= 1) {
        f[i][j - 1][0] += f[i - 1][j][0];
        f[i][j - 1][1] += f[i - 1][j][1];
      } else if (s[i] == '(') {
        f[i][j + 1][0] += f[i - 1][j][0];
        f[i][j + 1][1] += f[i - 1][j][1];
      } else if (s[i] == '?') {
        if (j >= 1) {
          f[i][j - 1][1] += f[i - 1][j][1];
          f[i][j - 1][1] += f[i - 1][j][0];
        }
        f[i][j + 1][0] += f[i - 1][j][0];
      }
    }
    ans += f[i][0][0];
    ans += f[i][0][1];
  }
  printf("%d\n", ans);
  return 0;
}
