program kadai
implicit none
integer  ::  i,nag,num,flag,j
character(len=200000)  ::  s

read(*,*) s
nag=len(s)
num=0

do i=1,nag-2
    if (s(i:i)=="A") then
        flag=0
        j=i
        do while(flag==0)
            j=j+1
            if (s(j:j+1)=="BB" .or. s(j:j+1)=="CC" .or. s(j-1:j+1)=="ACB") then
                flag=1
            end if
            if (s(j:j+1)=="BC") then
                num=num+1
            end if
        end do
    end if
end do

write(*,*) num

end program kadai