program main
implicit none
integer :: i, j, k, l, m
character :: s*200000


read(*,*) s
l = len_trim(s)
if( l.le.2 ) then
   write(*,'(i0)') 0
   stop
end if
k = 0
do 
   j = 0
   m = 1
   do while( m.le.l-2)
      i = m
      if( s(i:i+2) == 'ABC' ) then
!         if( s(i:i+5) == 'ABCABC' ) then
!            k = k + 3
!            j = 1
!            s(i:i+5) ='BCBCAA'
!            m = m + 6
!         else
            k = k + 1
            j = 1
            s(i:i+2) ='BCA'
            m = m + 3
!         end if
      else
         m = m + 1
      end if
   end do
   if( j == 0 ) then
      write(*,'(i0)') k
      stop
   end if
end do

end program main
