program kenken
 implicit none
 integer n, k, i, j, sum
 character(200000) s
 sum=0
 j=1
 k=len_trim(s)
 read*, s
 do i=j,k
  n=index(s,"ABC")
   if(n.ne.0) then
   s(n:n+2)="BCA"
   sum=sum+1
   j=n
   cycle
   else if(n.eq.0) then
   print*, sum
   return
   end if
 end do
end program