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

using namespace std;

typedef long long i64;

const int max_n = 100010;

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));
	int r = 0;
	for (int i = 0; i < n + 1; i++) {
		for (int j = 0; j < n + 2; j++) {
			int left = (j <= i)? i + 1: i, right = j;
			bool g = 1;
			for (int k = 0, c = 0, u = 0; k < n + 2; k++) {
				if (k == left) {
					u++;
				} else if (k == right) {
					u--;
				} else {
					if (s[c] == '(') {
						u++;
					} else {
						u--;
					}
					c++;
				}
				if (u < 0) {
					g = 0;
					break;
				}
			}
			if (g) {
				r++;
			}
		}
	}
	cout << r << endl;
	return 0;
}
