from collections import deque
s=list(input())
d=deque()
n=len(s)
acount=0
cnt=0
for i in range(n):
    d.append(s[i])
i=0
while i<n:
    if s[i]=="A":
        acount=acount+1
    elif (i<n-1)and(acount>0)and(s[i]=="B")and(s[i+1]=="C"):
        cnt=cnt+acount
        i=i+1
    else:
        acount=0
    i=i+1
    #print(acount,cnt)
    #input()
print(cnt) from collections import deque s=list(input()) s list(input()) list input() input d=deque() d deque() deque n=len(s) n len(s) len s acount=0 acount 0 cnt=0 cnt 0 for i in range(n):
    d.append(s[i]) i range(n) range n d.append(s[i]) d.append d append s[i] s i i=0 i 0 while i<n:
    if s[i]=="A":
        acount=acount+1
    elif (i<n-1)and(acount>0)and(s[i]=="B")and(s[i+1]=="C"):
        cnt=cnt+acount
        i=i+1
    else:
        acount=0
    i=i+1
    #print(acount,cnt)
    #input() i<n i n if s[i]=="A":
        acount=acount+1
    elif (i<n-1)and(acount>0)and(s[i]=="B")and(s[i+1]=="C"):
        cnt=cnt+acount
        i=i+1
    else:
        acount=0
     s[i]=="A" s[i] s i "A" acount=acount+1 acount acount+1 acount 1 elif (i<n-1)and(acount>0)and(s[i]=="B")and(s[i+1]=="C"):
        cnt=cnt+acount
        i=i+1
     (i<n-1)and(acount>0)and(s[i]=="B")and(s[i+1]=="C") (i<n-1)and(acount>0)and(s[i]=="B") (i<n-1)and(acount>0) i<n-1 i n-1 n 1 acount>0 acount 0 s[i]=="B" s[i] s i "B" s[i+1]=="C" s[i+1] s i+1 i 1 "C" cnt=cnt+acount cnt cnt+acount cnt acount i=i+1 i i+1 i 1 acount=0 acount 0 i=i+1 i i+1 i 1 print(cnt) print cnt acount=0 0 acount cnt=0 0 cnt i=0 0 i acount=0 0 acount i=i+1 i+1 i n=len(s) len(s) n cnt=cnt+acount cnt+acount cnt d=deque() deque() d acount=acount+1 acount+1 acount s=list(input()) list(input()) s i=i+1 i+1 i
from collections import deque
s=list(input())
d=deque()
n=len(s)
acount=0
cnt=0
for i in range(n):
    d.append(s[i])
i=0
while i<n:
    if s[i]=="A":
        acount=acount+1
    elif (i<n-1)and(acount>0)and(s[i]=="B")and(s[i+1]=="C"):
        cnt=cnt+acount
        i=i+1
    else:
        acount=0
    i=i+1
    #print(acount,cnt)
    #input()
print(cnt)