#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
int sgn(double x) { return (x > 1e-10) - (x < -1e-10); }
struct TPoint {
  double x, y;
  TPoint(double _x = 0, double _y = 0) : x(_x), y(_y) {}
  void show() {
    cout << "x" << '=' << x << " , ", cout << "y" << '=' << y << endl;
  }
};
bool operator!=(TPoint a, TPoint b) { return sgn(a.x - b.x) || sgn(a.y - b.y); }
bool operator==(TPoint a, TPoint b) {
  return !sgn(a.x - b.x) && !sgn(a.y - b.y);
}
bool operator<(TPoint a, TPoint b) {
  return sgn(a.x - b.x) ? sgn(a.x - b.x) == -1 : sgn(a.y - b.y) == -1;
}
TPoint operator-(TPoint a, TPoint b) { return TPoint(a.x - b.x, a.y - b.y); }
TPoint operator+(TPoint a, TPoint b) { return TPoint(a.x + b.x, a.y + b.y); }
TPoint operator*(TPoint a, double b) { return TPoint(a.x * b, a.y * b); }
TPoint operator/(TPoint a, double b) { return TPoint(a.x / b, a.y / b); }
TPoint rot90(TPoint a) { return TPoint(-a.y, a.x); }
double cross(TPoint a, TPoint b) { return (a.x * b.y - a.y * b.x); }
double cross(TPoint a, TPoint b, TPoint c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}
double dot(TPoint a, TPoint b) { return (a.x * b.x + a.y * b.y); }
double dot(TPoint a, TPoint b, TPoint c) {
  return (b.x - a.x) * (c.x - a.x) + (b.y - a.y) * (c.y - a.y);
}
double len(TPoint a) { return sqrt(a.x * a.x + a.y * a.y); }
double dis(TPoint a, TPoint b) { return len(a - b); }
bool seg_inter(TPoint a, TPoint b, TPoint c, TPoint d) {
  return max(a.x, b.x) >= min(c.x, d.x) && max(c.x, d.x) >= min(a.x, b.x) &&
         max(a.y, b.y) >= min(c.y, d.y) && max(c.y, d.y) >= min(a.y, b.y) &&
         sgn(cross(a, b, c)) * sgn(cross(a, b, d)) < 0 &&
         sgn(cross(c, d, a)) * sgn(cross(c, d, b)) < 0;
}
TPoint get_inter(TPoint a, TPoint b, TPoint c, TPoint d) {
  double s1 = cross(a, b, d), s2 = cross(c, a, b);
  return TPoint((s1 * c.x - s2 * d.x) / (s1 - s2),
                (s1 * c.y - s2 * d.y) / (s1 - s2));
}
bool on_segment(TPoint &c, TPoint &a, TPoint &b) {
  return sgn(cross(c, a, b)) == 0 && dot(c, a, b) < 0;
}
struct Circle {
  TPoint o;
  double r;
  Circle() {}
  Circle(TPoint _o, double _r) : o(_o), r(_r) {}
};
vector<TPoint> Circle_cross(Circle c1, Circle c2) {
  double d = len((c1.o - c2.o));
  vector<TPoint> ret;
  if (sgn(d - (c1.r + c2.r)) == 1 || sgn(d - fabs(c1.r - c2.r)) == -1)
    return ret;
  double d1 = (c1.r * c1.r + d * d - c2.r * c2.r) / 2.0 / d;
  TPoint dir = (c2.o - c1.o) / d, pcrs = c1.o + dir * d1;
  double dt = sqrt(max(0.0, c1.r * c1.r - d1 * d1));
  dir = rot90(dir);
  ret.push_back(pcrs + dir * dt);
  ret.push_back(pcrs - dir * dt);
  return ret;
}
const int maxn = 5005;
char s[maxn];
void gao(char ch, int &c1, int &c2, int &c3) {
  if (ch == '(') c1++;
  if (ch == ')') c2++;
  if (ch == '?') c3++;
}
int main() {
  cin >> s + 1;
  int len = strlen(s + 1);
  int ans = 0;
  for (int l = 1; l < (len + 1); ++l) {
    int mmin = 0, mmax = 0;
    for (int r = l; r < (len + 1); ++r) {
      if (s[r] == '(') mmin++, mmax++;
      if (s[r] == ')') mmin--, mmax--;
      if (s[r] == '?') mmin--, mmax++;
      if (mmax < 0) break;
      mmin = max(mmin, 0);
      if (mmin == 0 && (l - r + 1) % 2 == 0 && s[r] != '(') ans++;
    }
  }
  cout << ans << endl;
}
