s = gets.chomp
cnt = 0
while true
  ss = s.clone
  ss = ss.gsub(/ABC/,'*')

  if ss.count('*') > 0
    cnt += ss.count('*')
    ss.gsub!(/\*/,'BCA')
  else
    break
  end

  if s == ss
    break
  else
    s = ss.clone
  end
end

puts cnt
