from collections import deque

s=input()
s=s.replace("BC","D")
N=len(s)

cnt=0
cntA=0
cntD=0

for i in range(N):
  if s[i]=="A":
    cntA += 1
  elif s[i]=="D":
    cnt += cntA
  else:
    cntA=0
    cntD=0
    
print(cnt) from collections import deque s=input() s input() input s=s.replace("BC","D") s s.replace("BC","D") s.replace s replace "BC" "D" N=len(s) N len(s) len s cnt=0 cnt 0 cntA=0 cntA 0 cntD=0 cntD 0 for i in range(N):
  if s[i]=="A":
    cntA += 1
  elif s[i]=="D":
    cnt += cntA
  else:
    cntA=0
    cntD=0
     i range(N) range N if s[i]=="A":
    cntA += 1
  elif s[i]=="D":
    cnt += cntA
  else:
    cntA=0
    cntD=0
     s[i]=="A" s[i] s i "A" cntA += 1 cntA 1 elif s[i]=="D":
    cnt += cntA
   s[i]=="D" s[i] s i "D" cnt += cntA cnt cntA cntA=0 cntA 0 cntD=0 cntD 0 print(cnt) print cnt cnt += cntA cntA cnt cnt=0 0 cnt s=s.replace("BC","D") s.replace("BC","D") s cntA=0 0 cntA cntD=0 0 cntD cntA += 1 1 cntA cntA=0 0 cntA N=len(s) len(s) N s=input() input() s cntD=0 0 cntD
from collections import deque

s=input()
s=s.replace("BC","D")
N=len(s)

cnt=0
cntA=0
cntD=0

for i in range(N):
  if s[i]=="A":
    cntA += 1
  elif s[i]=="D":
    cnt += cntA
  else:
    cntA=0
    cntD=0
    
print(cnt)