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

using namespace std;

typedef long long i64;

const int max_n = 100001;

char s[max_n];
int main() {
#ifdef pperm
	freopen("input.txt", "r", stdin);
#else
	freopen("brackets.in", "r", stdin);
	freopen("brackets.out", "w", stdout);
#endif
	scanf("%s", s);
	int n = int(strlen(s));
	i64 res = 0;
	res = (n + 1LL) * (n + 2LL) / 2;//()
	for (int i = 0, u = 0, cnt = 0; s[i]; i++) {
		((s[i] == '(')? u++ : u--);
		if (u > 0) {
			cnt++;
			res += cnt;
		} else {
			cnt = 0;
		}
	}
	cout << res << endl;
	return 0;
}
