s=input()
s=s.replace("BC","D")
n=len(s)
ans=0
cnt=0
for i in range(n-1,-1,-1):
    if s[i]=="B" or s[i]=="C":
        cnt=0
    elif s[i]=="D":
        cnt+=1
    else:
        ans+=cnt
print(ans) s=input() s input() input s=s.replace("BC","D") s s.replace("BC","D") s.replace s replace "BC" "D" n=len(s) n len(s) len s ans=0 ans 0 cnt=0 cnt 0 for i in range(n-1,-1,-1):
    if s[i]=="B" or s[i]=="C":
        cnt=0
    elif s[i]=="D":
        cnt+=1
    else:
        ans+=cnt i range(n-1,-1,-1) range n-1 n 1 -1 -1 if s[i]=="B" or s[i]=="C":
        cnt=0
    elif s[i]=="D":
        cnt+=1
    else:
        ans+=cnt s[i]=="B" or s[i]=="C" s[i]=="B" s[i] s i "B" s[i]=="C" s[i] s i "C" cnt=0 cnt 0 elif s[i]=="D":
        cnt+=1
     s[i]=="D" s[i] s i "D" cnt+=1 cnt 1 ans+=cnt ans cnt print(ans) print ans s=input() input() s ans+=cnt cnt ans ans=0 0 ans cnt+=1 1 cnt s=s.replace("BC","D") s.replace("BC","D") s n=len(s) len(s) n cnt=0 0 cnt cnt=0 0 cnt
s=input()
s=s.replace("BC","D")
n=len(s)
ans=0
cnt=0
for i in range(n-1,-1,-1):
    if s[i]=="B" or s[i]=="C":
        cnt=0
    elif s[i]=="D":
        cnt+=1
    else:
        ans+=cnt
print(ans)
