{$N+,E-}
var
	i : longint;
	ans, j : comp;
	c : char;
	p : longint;

	curpos : longint;
	a : comp;
	inp, outp : text;
begin
	assign(inp, 'brackets.in');
	reset(inp);
	assign(outp, 'brackets.out');
	rewrite(outp);
	p := 0;
	curpos := 0;
	ans:= 0;
	while not eoln(inp) do begin
		read(inp, c);
		inc(curpos);
		if (c = '(') then 
			p := p + 1
		else 
			p := p - 1;

		if (p = 0) then begin
			inc(i);
			continue;
		end;
		i := curpos;
		j := curpos;
		while not eoln(inp) do begin
			read(inp, c);
			inc(curpos);
			j := j + 1;
			if (c = '(') then 
				p := p + 1
			else 
				p := p - 1;
			if p = 0 then break;
		end;
		ans := ans + (j - i + 1) * (j - i) / 2;
		if eoln(inp) then break;
	end;
	a := curpos;
	ans := ans + ((a + 1) * (a + 2)) / 2;
	writeln(outp, ans:0:0);
	close(inp);
	close(outp);
end.

