s=input()
n=0
c=0
i=0
while i<len(s):
  if s[i]=="A":
    c+=1
  elif s[i:i+2]=="BC":
    n+=c
    i+=1
  else:
    c=0
  i+=1
print(n) s=input() s input() input n=0 n 0 c=0 c 0 i=0 i 0 while i<len(s):
  if s[i]=="A":
    c+=1
  elif s[i:i+2]=="BC":
    n+=c
    i+=1
  else:
    c=0
  i+=1 i<len(s) i len(s) len s if s[i]=="A":
    c+=1
  elif s[i:i+2]=="BC":
    n+=c
    i+=1
  else:
    c=0
   s[i]=="A" s[i] s i "A" c+=1 c 1 elif s[i:i+2]=="BC":
    n+=c
    i+=1
   s[i:i+2]=="BC" s[i:i+2] s i:i+2 i i+2 i 2 "BC" n+=c n c i+=1 i 1 c=0 c 0 i+=1 i 1 print(n) print n s=input() input() s c=0 0 c n=0 0 n i+=1 1 i i+=1 1 i i=0 0 i c=0 0 c c+=1 1 c n+=c c n
s=input()
n=0
c=0
i=0
while i<len(s):
  if s[i]=="A":
    c+=1
  elif s[i:i+2]=="BC":
    n+=c
    i+=1
  else:
    c=0
  i+=1
print(n)
