import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputReader reader = new InputReader(System.in);
		char[] s = reader.next().toCharArray();
		long count = 0;
		int n = s.length;
		for (int i = 0; i < n; ++i) {
			if (s[i] == ')')
				continue;
			int question = 0;
			int open = 0;
			int close = 0;
			for (int j = i; j < n; j++) {
				boolean ok = true;
				if (s[j] == '(' || (j == i && s[j] == '?')) {
					open++;
				} else if (s[j] == '?') {
					question++;
				} else {
					close++;
				}

				if (close <= question + open && open <= question + close && s[j] != '(' && ((j - i + 1) & 1) == 0) {
					count++;
				} else if (close > question + open) {
					break;
				}
			}

		}
		System.out.println(count);
	}

	static class InputReader {
		StringTokenizer tokenizer;
		BufferedReader reader;
		String token;
		String temp;

		public InputReader(InputStream stream) {
			tokenizer = null;
			reader = new BufferedReader(new InputStreamReader(stream));
		}

		public InputReader(FileInputStream stream) {
			tokenizer = null;
			reader = new BufferedReader(new InputStreamReader(stream));
		}

		public String nextLine() throws IOException {
			return reader.readLine();
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					if (temp != null) {
						tokenizer = new StringTokenizer(temp);
						temp = null;
					} else {
						tokenizer = new StringTokenizer(reader.readLine());
					}

				} catch (IOException e) {
				}
			}
			return tokenizer.nextToken();
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}