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

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

do while(index(s,"AABCBC")/=0)
    ind=index(s,"AABCBC")
s(ind:ind+5)="ABCABC"
    num=num+1
end do

do while(index(s,"AABC")/=0)
    ind=index(s,"AABC")
s(ind:ind+3)="ABCA"
    num=num+1
end do

do while(index(s,"ABCBC")/=0)
    ind=index(s,"ABCBC")
s(ind:ind+4)="BCABC"
    num=num+1
end do

do while(index(s,"ABC")/=0)
    ind=index(s,"ABC")
s(ind:ind+2)="BCA"
    num=num+1
end do

write(*,*) num

end program kadai
