s=list(input())
x=[]
for i in range(len(s)):
    if s[i]=='A':
        x.append(0)
    elif s[i]=='B':
        x.append(1)
    elif i>0 and s[i]=='C' and s[i-1]=='B':
        x[-1]=3
    else:
        x.append(2)
ans=0
tmp0=0
for i in range(len(x)):
    if x[i]==0:
        tmp0+=1
    if x[i]==3:
        ans+=tmp0
    if x[i]!=0 and x[i]!=3:
        tmp0=0
print(ans) s=list(input()) s list(input()) list input() input x=[] x [] for i in range(len(s)):
    if s[i]=='A':
        x.append(0)
    elif s[i]=='B':
        x.append(1)
    elif i>0 and s[i]=='C' and s[i-1]=='B':
        x[-1]=3
    else:
        x.append(2) i range(len(s)) range len(s) len s if s[i]=='A':
        x.append(0)
    elif s[i]=='B':
        x.append(1)
    elif i>0 and s[i]=='C' and s[i-1]=='B':
        x[-1]=3
    else:
        x.append(2) s[i]=='A' s[i] s i 'A' x.append(0) x.append x append 0 elif s[i]=='B':
        x.append(1)
     s[i]=='B' s[i] s i 'B' x.append(1) x.append x append 1 elif i>0 and s[i]=='C' and s[i-1]=='B':
        x[-1]=3
     i>0 and s[i]=='C' and s[i-1]=='B' i>0 and s[i]=='C' i>0 i 0 s[i]=='C' s[i] s i 'C' s[i-1]=='B' s[i-1] s i-1 i 1 'B' x[-1]=3 x[-1] x -1 3 x.append(2) x.append x append 2 ans=0 ans 0 tmp0=0 tmp0 0 for i in range(len(x)):
    if x[i]==0:
        tmp0+=1
    if x[i]==3:
        ans+=tmp0
    if x[i]!=0 and x[i]!=3:
        tmp0=0 i range(len(x)) range len(x) len x if x[i]==0:
        tmp0+=1
     x[i]==0 x[i] x i 0 tmp0+=1 tmp0 1 if x[i]==3:
        ans+=tmp0
     x[i]==3 x[i] x i 3 ans+=tmp0 ans tmp0 if x[i]!=0 and x[i]!=3:
        tmp0=0 x[i]!=0 and x[i]!=3 x[i]!=0 x[i] x i 0 x[i]!=3 x[i] x i 3 tmp0=0 tmp0 0 print(ans) print ans ans+=tmp0 tmp0 ans x=[] [] x tmp0=0 0 tmp0 tmp0+=1 1 tmp0 tmp0=0 0 tmp0 s=list(input()) list(input()) s ans=0 0 ans
s=list(input())
x=[]
for i in range(len(s)):
    if s[i]=='A':
        x.append(0)
    elif s[i]=='B':
        x.append(1)
    elif i>0 and s[i]=='C' and s[i-1]=='B':
        x[-1]=3
    else:
        x.append(2)
ans=0
tmp0=0
for i in range(len(x)):
    if x[i]==0:
        tmp0+=1
    if x[i]==3:
        ans+=tmp0
    if x[i]!=0 and x[i]!=3:
        tmp0=0
print(ans)