s = input()
i = 0
p = []
tmp =[]
n = len(s)
while i<n-1:
    if(s[i]=="A" or s[i:i+2]=="BC"):
        if s[i]=="A":
            
            tmp.append(1)
            i+=1
        else:
            tmp.append(0)
            i+=2

    else:
        p.append(tmp)
        tmp = []
        i+=1
p.append(tmp)
res = 0
for i in range(len(p)):
    anum = 0
    bcnum = 0
    for j in range(len(p[i])):
        if p[i][j]:anum+=1
        else:
            res += (anum)
print(res) s = input() s input() input i = 0 i 0 p = [] p [] tmp =[] tmp [] n = len(s) n len(s) len s while i<n-1:
    if(s[i]=="A" or s[i:i+2]=="BC"):
        if s[i]=="A":
            
            tmp.append(1)
            i+=1
        else:
            tmp.append(0)
            i+=2

    else:
        p.append(tmp)
        tmp = []
        i+=1 i<n-1 i n-1 n 1 if(s[i]=="A" or s[i:i+2]=="BC"):
        if s[i]=="A":
            
            tmp.append(1)
            i+=1
        else:
            tmp.append(0)
            i+=2

    else:
        p.append(tmp)
        tmp = []
        i+=1 s[i]=="A" or s[i:i+2]=="BC" s[i]=="A" s[i] s i "A" s[i:i+2]=="BC" s[i:i+2] s i:i+2 i i+2 i 2 "BC" if s[i]=="A":
            
            tmp.append(1)
            i+=1
        else:
            tmp.append(0)
            i+=2

     s[i]=="A" s[i] s i "A" tmp.append(1) tmp.append tmp append 1 i+=1 i 1 tmp.append(0) tmp.append tmp append 0 i+=2 i 2 p.append(tmp) p.append p append tmp tmp = [] tmp [] i+=1 i 1 p.append(tmp) p.append p append tmp res = 0 res 0 for i in range(len(p)):
    anum = 0
    bcnum = 0
    for j in range(len(p[i])):
        if p[i][j]:anum+=1
        else:
            res += (anum) i range(len(p)) range len(p) len p anum = 0 anum 0 bcnum = 0 bcnum 0 for j in range(len(p[i])):
        if p[i][j]:anum+=1
        else:
            res += (anum) j range(len(p[i])) range len(p[i]) len p[i] p i if p[i][j]:anum+=1
        else:
            res += (anum) p[i][j] [i] p i j res += (anum) res anum print(res) print res anum = 0 0 anum i+=2 2 i s = input() input() s i = 0 0 i p = [] [] p bcnum = 0 0 bcnum res += (anum) anum res tmp =[] [] tmp tmp = [] [] tmp res = 0 0 res n = len(s) len(s) n i+=1 1 i i+=1 1 i
s = input()
i = 0
p = []
tmp =[]
n = len(s)
while i<n-1:
    if(s[i]=="A" or s[i:i+2]=="BC"):
        if s[i]=="A":
            
            tmp.append(1)
            i+=1
        else:
            tmp.append(0)
            i+=2

    else:
        p.append(tmp)
        tmp = []
        i+=1
p.append(tmp)
res = 0
for i in range(len(p)):
    anum = 0
    bcnum = 0
    for j in range(len(p[i])):
        if p[i][j]:anum+=1
        else:
            res += (anum)
print(res)
