#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

typedef long long i64;

const int max_n = 100001;

char s[max_n];
int main() {
	freopen("brackets.in", "r", stdin);
	freopen("brackets.out", "w", stdout);
	scanf("%s", s);
	int n = int(strlen(s));
	i64 res = 0;
	res = (n + 1LL) * (n + 2LL) / 2;//()
		int p[n + 1];
		for (int i = 1; i <= n; i++) {
			p[i] = p[i - 1] + (s[i - 1] == '(' ? 1 : -1);
		}
		for (int i = 0; i <= n; i++) {
		   int j;
			for (j = i;p[j] != 0; j++) {
			}
			res += j - i;
		}
	cout << res << endl;
	return 0;
}
