s=input()

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

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

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

print(ans)
