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

local total = 0

if #b >= 3 then
    local numA = 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
end

print(total)