s=input().replace("BC","X")
ans=0
acc=0
for i in range(len(s)):
    if s[i]=="B" or s[i]=="C":
        acc=0

    elif s[i]=="A":
        acc+=1
    elif s[i]=="X":
        ans+=acc


print(ans) s=input().replace("BC","X") s input().replace("BC","X") ().replace () input replace "BC" "X" ans=0 ans 0 acc=0 acc 0 for i in range(len(s)):
    if s[i]=="B" or s[i]=="C":
        acc=0

    elif s[i]=="A":
        acc+=1
    elif s[i]=="X":
        ans+=acc i range(len(s)) range len(s) len s if s[i]=="B" or s[i]=="C":
        acc=0

    elif s[i]=="A":
        acc+=1
    elif s[i]=="X":
        ans+=acc s[i]=="B" or s[i]=="C" s[i]=="B" s[i] s i "B" s[i]=="C" s[i] s i "C" acc=0 acc 0 elif s[i]=="A":
        acc+=1
     s[i]=="A" s[i] s i "A" acc+=1 acc 1 elif s[i]=="X":
        ans+=acc s[i]=="X" s[i] s i "X" ans+=acc ans acc print(ans) print ans acc=0 0 acc acc+=1 1 acc s=input().replace("BC","X") input().replace("BC","X") s ans=0 0 ans ans+=acc acc ans acc=0 0 acc
s=input().replace("BC","X")
ans=0
acc=0
for i in range(len(s)):
    if s[i]=="B" or s[i]=="C":
        acc=0

    elif s[i]=="A":
        acc+=1
    elif s[i]=="X":
        ans+=acc


print(ans)