import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class brackets_sm_wrong2 {
	private static final int MAXLEN = 100000;
	private static final int MINLEN = 2;

	void solve() throws IOException {
		String s = br.readLine();
		assert MINLEN <= s.length() && s.length() <= MAXLEN;
		assert check(s);
		long n = s.length();
		long ans = n / 2 + (n + 1) * (n + 2) / 2;
		System.err.println(ans);
		out.println(ans);
	}

	boolean check(String s) {
		int open = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '(') {
				open++;
			} else if (s.charAt(i) == ')') {
				open--;
			} else {
				throw new AssertionError();
			}
			if (open < 0) {
				return false;
			}
		}
		return open == 0;
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	public void run() {
		try {
			String filename = this.getClass().getName()
					.substring(0, this.getClass().getName().indexOf("_"));
			br = new BufferedReader(new FileReader(filename + ".in"));
			out = new PrintWriter(filename + ".out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	String nextToken() {
		try {
			while (st == null || !st.hasMoreTokens()) {
				String s = br.readLine();
				if (s == null) {
					return null;
				}
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Integer.parseInt(nextToken());
	}

	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new brackets_sm_wrong2().run();
	}
}
