
local s = io.read()
-- s = "ABCABC"
-- s = "ABCACCBABCBCAABCB"
local c = {}
for i = 1, #s do
	c[i] = string.sub(s, i, i)
end
-- print_r(c)

local num = 0
local i = 1
while i <= #c - 2 do
	if c[i] == "A" then
		-- print(222, i, c[i], c[i+1], c[i+2])
		if c[i+1] == "B" and c[i+2] == "C" then
			c[i] = "B"
			c[i+1] = "C"
			c[i+2] = "A"
			i = i - 1
			if i <= 0 then
				i = 1
			end
			num = num + 1
		else
			i = i + 1
		end
	else
		i = i + 1
	end
end
print(num)