var
s:ansistring;
ans,x:int64;
i,j:longint;
begin
assign(input,'cowfind.in'); reset(input);
assign(output,'cowfind.out');rewrite(output);
readln(s);
j:=1;
for i:=1 to length(s)-1 do
begin
inc(j);
if (s[i]='(') and (s[j]='(')
then inc(x);
if (s[i]=')') and (s[j]=')')
then ans:=ans+x;
end;
writeln(ans);
close(input);close(output);
end.