s=gets.chomp
last_i=s.size-1
il = []
from = 0
while(i = s.index("ABC", from)) do
  il << i
  from = i+1
end


cnt=0
#il.each do |i|
while(i = il.shift ) do
  cnt+=1
  s[i..(i+2)]="BCA"
  il.unshift i-1 if i != 0 and s[i-1] == "A"
  il.unshift i+2 if i+2+2 <= last_i and s[(i+2)+1] == "B" and s[(i+2)+2] == "C"
end
puts cnt