s = gets.chomp

i = 0
counter = 0

len = s.length

if len < 3
	puts 0
	exit
end

while i != len - 1 - 1
	if s[i..i+2] == 'ABC'
		s[i..i+2] = 'BCA'
		counter += 1
		if i != 0
			i -= 1
		end
	else
		i += 1
	end
end

puts counter