s=list(input())
n=len(s)
l=[]
i=0
while i<n:
    if i<n-1 and s[i]=='B' and s[i+1]=='C':
        l.append('D')
        i+=2
    else:
        l.append(s[i])
        i+=1
n=len(l)
ans=0
r=[0]*(n+1)
f=0
for i in range(n-1,-1,-1):
    if l[i]=='D':
        f+=1
    elif l[i]=='A':
        ans+=f
    else:
        f=0
print(ans) s=list(input()) s list(input()) list input() input n=len(s) n len(s) len s l=[] l [] i=0 i 0 while i<n:
    if i<n-1 and s[i]=='B' and s[i+1]=='C':
        l.append('D')
        i+=2
    else:
        l.append(s[i])
        i+=1 i<n i n if i<n-1 and s[i]=='B' and s[i+1]=='C':
        l.append('D')
        i+=2
    else:
        l.append(s[i])
        i+=1 i<n-1 and s[i]=='B' and s[i+1]=='C' i<n-1 and s[i]=='B' i<n-1 i n-1 n 1 s[i]=='B' s[i] s i 'B' s[i+1]=='C' s[i+1] s i+1 i 1 'C' l.append('D') l.append l append 'D' i+=2 i 2 l.append(s[i]) l.append l append s[i] s i i+=1 i 1 n=len(l) n len(l) len l ans=0 ans 0 r=[0]*(n+1) r [0]*(n+1) [0] 0 n+1 n 1 f=0 f 0 for i in range(n-1,-1,-1):
    if l[i]=='D':
        f+=1
    elif l[i]=='A':
        ans+=f
    else:
        f=0 i range(n-1,-1,-1) range n-1 n 1 -1 -1 if l[i]=='D':
        f+=1
    elif l[i]=='A':
        ans+=f
    else:
        f=0 l[i]=='D' l[i] l i 'D' f+=1 f 1 elif l[i]=='A':
        ans+=f
     l[i]=='A' l[i] l i 'A' ans+=f ans f f=0 f 0 print(ans) print ans i+=2 2 i n=len(l) len(l) n l=[] [] l r=[0]*(n+1) [0]*(n+1) r f=0 0 f f+=1 1 f f=0 0 f s=list(input()) list(input()) s ans=0 0 ans ans+=f f ans i+=1 1 i n=len(s) len(s) n i=0 0 i
s=list(input())
n=len(s)
l=[]
i=0
while i<n:
    if i<n-1 and s[i]=='B' and s[i+1]=='C':
        l.append('D')
        i+=2
    else:
        l.append(s[i])
        i+=1
n=len(l)
ans=0
r=[0]*(n+1)
f=0
for i in range(n-1,-1,-1):
    if l[i]=='D':
        f+=1
    elif l[i]=='A':
        ans+=f
    else:
        f=0
print(ans)
