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

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

do while(index(s,"AABCBC")/=0)
    do i=1,nag-5
        if (s(i:i+5)=="AABCBC") then
            s(i:i+5)="ABCABC"
            num=num+1
        end if
    end do
end do

do while(index(s,"AABC")/=0)
    do i=1,nag-3
        if (s(i:i+3)=="AABC") then
            s(i:i+3)="ABCA"
            num=num+1
        end if
    end do
end do

do while(index(s,"ABCBC")/=0)
    do i=1,nag-4
        if (s(i:i+4)=="ABCBC") then
            s(i:i+4)="BCABC"
            num=num+1
        end if
    end do
end do

do while(index(s,"ABC")/=0)
    do i=1,nag-2
        if (s(i:i+2)=="ABC") then
            s(i:i+2)="BCA"
            num=num+1
        end if
    end do
end do

write(*,*) num

end program kadai