#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstring>
#include <string>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <climits>
#include <queue>
#include <deque>
#include <list>
#include <forward_list>
#include <sstream>
#include <complex>
#include <iterator>
#include <functional>
#include <tuple>
#include <array>
#include <locale>
#include <memory>
#include <cstdio>
#define fin freopen("input.txt", "r", stdin);
#define fout freopen("output.txt", "w", stdout);
#define speedup ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cp(x) cout.setf(ios::fixed); cout.precision(x);
#define loop(i, x, n) for(int i = x; i <= n; ++i)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mem(a,b) memset(a, b, sizeof(a))
#define cpy(a,b,x) memcpy(a, b, sizeof(x))
#define ST(N) srand(time(NULL))
#define SQ(x) (x)*(x)
#define ad push_back
#define mp make_pair
#define fr first
#define sc second
#define vc vector
#define vi vector<int>
#define pqi priority_queue<int>
#define pii pair<int, int>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
//#define DEBUG
//#define TEST 1
typedef long long ll;
typedef long double ld;
typedef double dbl;
typedef unsigned long long ull;
using namespace std;
const int N = (int)1e6 + 100;
const int MOD = (int)1e9 + 7;
const int INF = INT_MAX;
const ll INF_ll = LLONG_MAX;
const ull INF_ull = ULLONG_MAX;
long long cnt = 0, ans = 0;
vector <int> dp(N);
bool u = false, U[N];
int a[N], b[N], c[N];
int A[N / 1000][N / 1000];
int gcd(const int x, const int y) {
return y ? gcd(y, x % y) : x;
}
bool is_even(int x) {
return 1 - (x & 1);
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define FREOPEN
#ifdef FREOPEN
#ifndef _MSC_VER
#define TASK ""
freopen(TASK".in", "r", stdin);
freopen(TASK".out", "w", stdout);
#endif
#endif
string s;
cin >> s;
int i, j, ans = 0;
for (i = 0; i<s.length(); i++)
{
int p = 0, x = 0;
for (j = i; j<s.length(); j++)
{
if (s[j] == '(') p++;
if (s[j] == ')') p--;
if (s[j] == '?')
{
x++;
p--;
}
if (p == 0) ans++;
if (p<0)
{
if (x == 0) break;
x--;
p += 2;
}
}
}
cout << ans << endl;
return 0;
}
I2RlZmluZSBfQ1JUX1NFQ1VSRV9OT19XQVJOSU5HUwojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxmc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3RpbWU+CiNpbmNsdWRlIDxtYXA+CiNpbmNsdWRlIDx1bm9yZGVyZWRfbWFwPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8dW5vcmRlcmVkX3NldD4KI2luY2x1ZGUgPGJpdHNldD4KI2luY2x1ZGUgPGxpbWl0cz4KI2luY2x1ZGUgPGNsaW1pdHM+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPGRlcXVlPgojaW5jbHVkZSA8bGlzdD4KI2luY2x1ZGUgPGZvcndhcmRfbGlzdD4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxjb21wbGV4PgojaW5jbHVkZSA8aXRlcmF0b3I+CiNpbmNsdWRlIDxmdW5jdGlvbmFsPgojaW5jbHVkZSA8dHVwbGU+CiNpbmNsdWRlIDxhcnJheT4gCiNpbmNsdWRlIDxsb2NhbGU+CiNpbmNsdWRlIDxtZW1vcnk+CiNpbmNsdWRlIDxjc3RkaW8+CiNkZWZpbmUgZmluIGZyZW9wZW4oImlucHV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