program abc
  implicit none
  character(200000) :: s
  integer :: n, m, i
  read(*,*) s
  s = trim(adjustl(s))
  n = len_trim(s)
  if (n.lt.3) then
    write(*,'(i0)') 0
    stop
  end if
  m = 0
  i = 1
  do while (i.le.n-2)
    if (s(i:i+2).eq."ABC") then
      s(i:i+2) = "BCA"
      m = m+1
      i = max(1,i-1)
    else
      i = i+1
    end if
  end do
  write(*,'(i0)') m
  stop
end program abc