from sys import stdin
s = (stdin.readline().rstrip())
s = s.replace("BC","D")
ans = 0
acc = 0

for i in s:
    if i == "B" or i == "C":
        acc = 0
        continue
        
    if i == "A":
        acc += 1
    
    if i == "D":
        ans += acc

print(ans) from sys import stdin s = (stdin.readline().rstrip()) s stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip s = s.replace("BC","D") s s.replace("BC","D") s.replace s replace "BC" "D" ans = 0 ans 0 acc = 0 acc 0 for i in s:
    if i == "B" or i == "C":
        acc = 0
        continue
        
    if i == "A":
        acc += 1
    
    if i == "D":
        ans += acc i s if i == "B" or i == "C":
        acc = 0
        continue
        
     i == "B" or i == "C" i == "B" i "B" i == "C" i "C" acc = 0 acc 0 continue if i == "A":
        acc += 1
    
     i == "A" i "A" acc += 1 acc 1 if i == "D":
        ans += acc i == "D" i "D" ans += acc ans acc print(ans) print ans acc = 0 0 acc acc += 1 1 acc ans = 0 0 ans ans += acc acc ans s = (stdin.readline().rstrip()) stdin.readline().rstrip() s acc = 0 0 acc s = s.replace("BC","D") s.replace("BC","D") s
from sys import stdin
s = (stdin.readline().rstrip())
s = s.replace("BC","D")
ans = 0
acc = 0

for i in s:
    if i == "B" or i == "C":
        acc = 0
        continue
        
    if i == "A":
        acc += 1
    
    if i == "D":
        ans += acc

print(ans)