S = gets.chomp
ans = 0
if S.size >= 3
  0.upto(S.size()-2) do |i|
    if S[(i)..(i+2)] == 'ABC'
      tmp=0
      j=i
      while j>=0 do
        if S[j] == 'A'
          tmp+=1
          j-=1
        else
          break
        end
      end
      ans+=tmp
      s='BC'+'A'*tmp
      S[(j+1)..(j+s.size())]=s
    end
  end
end
puts ans