s=input()
n=len(s)
ans=0
current=0
flag=0
for i in range(n-1):
  if flag==1:
    flag=0
    continue
  if s[i]=='B' and s[i+1]=='C':
    ans+=current
    flag=1
  elif s[i]=='A':
    current+=1
  else:
    current=0
print(ans) s=input() s input() input n=len(s) n len(s) len s ans=0 ans 0 current=0 current 0 flag=0 flag 0 for i in range(n-1):
  if flag==1:
    flag=0
    continue
  if s[i]=='B' and s[i+1]=='C':
    ans+=current
    flag=1
  elif s[i]=='A':
    current+=1
  else:
    current=0 i range(n-1) range n-1 n 1 if flag==1:
    flag=0
    continue
   flag==1 flag 1 flag=0 flag 0 continue if s[i]=='B' and s[i+1]=='C':
    ans+=current
    flag=1
  elif s[i]=='A':
    current+=1
  else:
    current=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' ans+=current ans current flag=1 flag 1 elif s[i]=='A':
    current+=1
   s[i]=='A' s[i] s i 'A' current+=1 current 1 current=0 current 0 print(ans) print ans flag=0 0 flag n=len(s) len(s) n flag=0 0 flag current=0 0 current ans+=current current ans s=input() input() s current+=1 1 current current=0 0 current ans=0 0 ans flag=1 1 flag
s=input()
n=len(s)
ans=0
current=0
flag=0
for i in range(n-1):
  if flag==1:
    flag=0
    continue
  if s[i]=='B' and s[i+1]=='C':
    ans+=current
    flag=1
  elif s[i]=='A':
    current+=1
  else:
    current=0
print(ans)