ans=0
for x in input().replace('BC','y').replace('A','x').replace('B',' ').replace('C',' ').split():
    c=0
    for t in x:
        if t=='y':
            ans+=c
        else:c+=1
print(ans) ans=0 ans 0 for x in input().replace('BC','y').replace('A','x').replace('B',' ').replace('C',' ').split():
    c=0
    for t in x:
        if t=='y':
            ans+=c
        else:c+=1 x input().replace('BC','y').replace('A','x').replace('B',' ').replace('C',' ').split() ().replace('BC','y').replace('A','x').replace('B',' ').replace('C',' ').split ().replace('BC','y').replace('A','x').replace('B',' ').replace('C',' ') ().replace('BC','y').replace('A','x').replace('B',' ').replace ().replace('BC','y').replace('A','x').replace('B',' ') ().replace('BC','y').replace('A','x').replace ().replace('BC','y').replace('A','x') ().replace('BC','y').replace ().replace('BC','y') ().replace () input replace 'BC' 'y' replace 'A' 'x' replace 'B' ' ' replace 'C' ' ' split c=0 c 0 for t in x:
        if t=='y':
            ans+=c
        else:c+=1 t x if t=='y':
            ans+=c
        else:c+=1 t=='y' t 'y' ans+=c ans c print(ans) print ans ans=0 0 ans ans+=c c ans c=0 0 c
ans=0
for x in input().replace('BC','y').replace('A','x').replace('B',' ').replace('C',' ').split():
    c=0
    for t in x:
        if t=='y':
            ans+=c
        else:c+=1
print(ans)