local a = io.read("*l")
local b = {}
for i = 1, string.len(a) do
    table.insert(b,string.sub(a,i,i))
end

if #b < 3 then
    return 0
end

local numA = 0
local total = 0
local i = 0
while i < #b do
    if b[i] == 'A' then
        numA = numA + 1
    elseif (b[i] == 'B' and b[i + 1] == 'C') then
        total = total + numA
        i = i + 1
    else
        numA = 0
    end

    i = i + 1
end

print(total)