s=input().replace('BC','D')
a=[]
b=''
for c in s:
    if c=='B' or c=='C':
        a.append(b)
        b=''
    else:
        b+=c
a.append(b)
ans=0
for i in a:
    ac=0
    for j in i:
        if j=='A':
            ac+=1
        else:
            ans+=ac
print(ans) s=input().replace('BC','D') s input().replace('BC','D') ().replace () input replace 'BC' 'D' a=[] a [] b='' b '' for c in s:
    if c=='B' or c=='C':
        a.append(b)
        b=''
    else:
        b+=c c s if c=='B' or c=='C':
        a.append(b)
        b=''
    else:
        b+=c c=='B' or c=='C' c=='B' c 'B' c=='C' c 'C' a.append(b) a.append a append b b='' b '' b+=c b c a.append(b) a.append a append b ans=0 ans 0 for i in a:
    ac=0
    for j in i:
        if j=='A':
            ac+=1
        else:
            ans+=ac i a ac=0 ac 0 for j in i:
        if j=='A':
            ac+=1
        else:
            ans+=ac j i if j=='A':
            ac+=1
        else:
            ans+=ac j=='A' j 'A' ac+=1 ac 1 ans+=ac ans ac print(ans) print ans b+=c c b ac=0 0 ac b='' '' b ans+=ac ac ans ac+=1 1 ac a=[] [] a s=input().replace('BC','D') input().replace('BC','D') s ans=0 0 ans b='' '' b
s=input().replace('BC','D')
a=[]
b=''
for c in s:
    if c=='B' or c=='C':
        a.append(b)
        b=''
    else:
        b+=c
a.append(b)
ans=0
for i in a:
    ac=0
    for j in i:
        if j=='A':
            ac+=1
        else:
            ans+=ac
print(ans)