S = str(input())
S = S.replace("BC","D")
A_count = 0
ans = 0

for i in range(len(S)):
  if S[i] == 'A':
    A_count += 1
  elif S[i] == 'D':
    ans += A_count
  else:
    A_count = 0
print(ans) S = str(input()) S str(input()) str input() input S = S.replace("BC","D") S S.replace("BC","D") S.replace S replace "BC" "D" A_count = 0 A_count 0 ans = 0 ans 0 for i in range(len(S)):
  if S[i] == 'A':
    A_count += 1
  elif S[i] == 'D':
    ans += A_count
  else:
    A_count = 0 i range(len(S)) range len(S) len S if S[i] == 'A':
    A_count += 1
  elif S[i] == 'D':
    ans += A_count
  else:
    A_count = 0 S[i] == 'A' S[i] S i 'A' A_count += 1 A_count 1 elif S[i] == 'D':
    ans += A_count
   S[i] == 'D' S[i] S i 'D' ans += A_count ans A_count A_count = 0 A_count 0 print(ans) print ans S = str(input()) str(input()) S A_count = 0 0 A_count ans = 0 0 ans A_count = 0 0 A_count ans += A_count A_count ans A_count += 1 1 A_count S = S.replace("BC","D") S.replace("BC","D") S
S = str(input())
S = S.replace("BC","D")
A_count = 0
ans = 0

for i in range(len(S)):
  if S[i] == 'A':
    A_count += 1
  elif S[i] == 'D':
    ans += A_count
  else:
    A_count = 0
print(ans)