program main
implicit none
integer :: i, j, k, l
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
   do i = 1, l-2
      if( s(i:i+2) == 'ABC' ) then
         k = k + 1
         j = 1
         s(i:i+2) ='BCA'
      end if
   end do
   if( j == 0 ) then
      write(*,'(i0)') k
      stop
   end if
end do

end program main
