def calc(sum,cnt,len)
  k = (len*2 -cnt + 1)
  return k * cnt / 2 - sum
end

s = gets.chomp
len,sum,cnt,ans = 0,0,0,0
i = 0
while i < s.length
  if s[i] == "A"
    len += 1
    sum += len
    cnt += 1
  elsif s[i] == "B"
    if s[i+1] != "C"
      ans += calc(sum,cnt,len)
      len,sum,cnt = 0,0,0
    else
      len += 1
      i += 1
    end
  else
    ans += calc(sum,cnt,len)
    len,sum,cnt = 0,0,0
  end
  #p [i,len,cnt,sum,ans]
  i += 1
end
ans += calc(sum,cnt,len)
p ans