s = input()
a = 0
ans = 0
n = len(s)
i = 0
while(i<n):
  if s[i] == "A":
    a += 1
  elif s[i] == "B" and i+1<n and s[i+1] == "C":
    ans += a
    i += 1
  else:
    a = 0
  i += 1
print(ans) s = input() s input() input a = 0 a 0 ans = 0 ans 0 n = len(s) n len(s) len s i = 0 i 0 while(i<n):
  if s[i] == "A":
    a += 1
  elif s[i] == "B" and i+1<n and s[i+1] == "C":
    ans += a
    i += 1
  else:
    a = 0
  i += 1 i<n i n if s[i] == "A":
    a += 1
  elif s[i] == "B" and i+1<n and s[i+1] == "C":
    ans += a
    i += 1
  else:
    a = 0
   s[i] == "A" s[i] s i "A" a += 1 a 1 elif s[i] == "B" and i+1<n and s[i+1] == "C":
    ans += a
    i += 1
   s[i] == "B" and i+1<n and s[i+1] == "C" s[i] == "B" and i+1<n s[i] == "B" s[i] s i "B" i+1<n i+1 i 1 n s[i+1] == "C" s[i+1] s i+1 i 1 "C" ans += a ans a i += 1 i 1 a = 0 a 0 i += 1 i 1 print(ans) print ans i += 1 1 i ans = 0 0 ans n = len(s) len(s) n a += 1 1 a a = 0 0 a s = input() input() s i = 0 0 i a = 0 0 a ans += a a ans i += 1 1 i
s = input()
a = 0
ans = 0
n = len(s)
i = 0
while(i<n):
  if s[i] == "A":
    a += 1
  elif s[i] == "B" and i+1<n and s[i+1] == "C":
    ans += a
    i += 1
  else:
    a = 0
  i += 1
print(ans)