s=input().replace("BC","D")
s=s+"0"
count=0
ans=0
for i in range(len(s)):
    if s[i]=="A":
        count+=1
    elif s[i]=="D":
        ans+=count
    else:
        count=0
print(ans) s=input().replace("BC","D") s input().replace("BC","D") ().replace () input replace "BC" "D" s=s+"0" s s+"0" s "0" count=0 count 0 ans=0 ans 0 for i in range(len(s)):
    if s[i]=="A":
        count+=1
    elif s[i]=="D":
        ans+=count
    else:
        count=0 i range(len(s)) range len(s) len s if s[i]=="A":
        count+=1
    elif s[i]=="D":
        ans+=count
    else:
        count=0 s[i]=="A" s[i] s i "A" count+=1 count 1 elif s[i]=="D":
        ans+=count
     s[i]=="D" s[i] s i "D" ans+=count ans count count=0 count 0 print(ans) print ans s=s+"0" s+"0" s s=input().replace("BC","D") input().replace("BC","D") s ans+=count count ans count+=1 1 count count=0 0 count ans=0 0 ans count=0 0 count
s=input().replace("BC","D")
s=s+"0"
count=0
ans=0
for i in range(len(s)):
    if s[i]=="A":
        count+=1
    elif s[i]=="D":
        ans+=count
    else:
        count=0
print(ans)