s = gets 
res = 0
#p s
flag = true

i = 0
n = s.size
flag_A = false
sz_A = sz_BC = 0
flag = false

while i < n
	if s[i] == "A"
		flag_A = true
		j = i
		i += 1 while s[i+1] == "A"
#		p s[j-1..i+1], s[j..i].size
#		print sz_A,"->"
		sz_A +=  i - j + 1 
#		print sz_A,"\n"
#		print "A"*sz_A
		i += 1
#		p ["size_A",sz_A]
	elsif s[i,2] == "BC"
	#	p "BC"
		j = i
		i += 2 while s[i,2] == "BC"
		sz_BC = i - j  >> 1
#		print "BC"*sz_BC
		res += sz_A * sz_BC
#		i += 1
#		p ["size_BC,size_A",sz_BC,sz_A]
	else
		i += 1
		sz_A = 0
		flag_A = false
	end
#	p ["i,res,szA,szB",i,res,sz_A,sz_BC]
end
p res