s = gets().chomp()

count = 0
i = 0

while i < s.length - 2
	if s[i] == "A" && s[i + 1] == "B" && s[i + 2] == "C"
		s[i] = "B"; s[i + 1] = "C"; s[i + 2] = "A"
		count += 1
		i -= 2
	else
		i += 1
	end
end

puts count
