local str = io.read()
local ans = 0
local tbl = {}
for i=1, string.len(str) do
	tbl[i] = string.sub(str,i,i)
end

local i = 1
while i< #tbl do
	local flag = false
	if tbl[i] == "A" and tbl[i+1] == "B" and tbl[i+2] == "C" then
		ans = ans + 1
		tbl[i] = "B"
		tbl[i+1] = "C"
		tbl[i+2] = "A"

		if i>2 then
			flag = true
			i = i-2
		end
	end
	if not flag then
		i = i+1
	end
end
print(ans)
