s=input() 
n=len(s)
cnt=0
temp=[0]*n
JinA=[] 
for i in range(n-1):
    if s[i]=="A":
        if i>0:
            temp[i]+=temp[i-1]+1 
        else:
            temp[i]+=1
    if s[i]=="B" and s[i+1]=="C" and i>0:
        temp[i+1]+=temp[i-1]
        cnt+=temp[i-1] 

print(cnt) s=input() s input() input n=len(s) n len(s) len s cnt=0 cnt 0 temp=[0]*n temp [0]*n [0] 0 n JinA=[] JinA [] for i in range(n-1):
    if s[i]=="A":
        if i>0:
            temp[i]+=temp[i-1]+1 
        else:
            temp[i]+=1
    if s[i]=="B" and s[i+1]=="C" and i>0:
        temp[i+1]+=temp[i-1]
        cnt+=temp[i-1]  i range(n-1) range n-1 n 1 if s[i]=="A":
        if i>0:
            temp[i]+=temp[i-1]+1 
        else:
            temp[i]+=1
     s[i]=="A" s[i] s i "A" if i>0:
            temp[i]+=temp[i-1]+1 
        else:
            temp[i]+=1
     i>0 i 0 temp[i]+=temp[i-1]+1 temp[i] temp i temp[i-1]+1 temp[i-1] temp i-1 i 1 1 temp[i]+=1 temp[i] temp i 1 if s[i]=="B" and s[i+1]=="C" and i>0:
        temp[i+1]+=temp[i-1]
        cnt+=temp[i-1]  s[i]=="B" and s[i+1]=="C" and i>0 s[i]=="B" and s[i+1]=="C" s[i]=="B" s[i] s i "B" s[i+1]=="C" s[i+1] s i+1 i 1 "C" i>0 i 0 temp[i+1]+=temp[i-1] temp[i+1] temp i+1 i 1 temp[i-1] temp i-1 i 1 cnt+=temp[i-1] cnt temp[i-1] temp i-1 i 1 print(cnt) print cnt JinA=[] [] JinA cnt+=temp[i-1] temp[i-1] cnt cnt=0 0 cnt s=input() input() s n=len(s) len(s) n temp=[0]*n [0]*n temp
s=input() 
n=len(s)
cnt=0
temp=[0]*n
JinA=[] 
for i in range(n-1):
    if s[i]=="A":
        if i>0:
            temp[i]+=temp[i-1]+1 
        else:
            temp[i]+=1
    if s[i]=="B" and s[i+1]=="C" and i>0:
        temp[i+1]+=temp[i-1]
        cnt+=temp[i-1] 

print(cnt)