local s = io.read()
local anum = 0
local num = 0
for i=1,string.len(s)-1 do
	local a = string.sub(s, i, i)
	local b = string.sub(s, i, i+1)
	if a == "A" then
		anum = anum + 1
	elseif  b == "BC" then
		num = anum + num
	else
		if i > 1 and string.sub(s, i-1, i) ~= "BC" then
			anum = 0
		end
	end
end
print(num)