#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
s = s.replace("BC", "D")
n = len(s)
for i in range (n):
  if s[i] == "A":
    count += 1
  elif s[i] == "D":
    ans += count
  else:
    count = 0
print(ans)
 import sys, math, itertools, collections, bisect sys math itertools collections bisect input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') input lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.stdin.buffer.readline().rstrip().decode sys.stdin.buffer.readline().rstrip() sys.stdin.buffer.readline().rstrip sys.stdin.buffer.readline() sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline rstrip decode 'utf-8' inf = float('inf') inf float('inf') float 'inf' mod = 10**9+7 mod 10**9+7 10**9 10 9 7 mans = inf mans inf ans = 0 ans 0 count = 0 count 0 pro = 1 pro 1 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 for i in range (n):
  if s[i] == "A":
    count += 1
  elif s[i] == "D":
    ans += count
  else:
    count = 0 i range (n) range n if s[i] == "A":
    count += 1
  elif s[i] == "D":
    ans += count
  else:
    count = 0 s[i] == "A" s[i] s i "A" count += 1 count 1 elif s[i] == "D":
    ans += count
   s[i] == "D" s[i] s i "D" ans += count ans count count = 0 count 0 print(ans) print ans s = input() input() s mans = inf inf mans n = len(s) len(s) n input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') input mod = 10**9+7 10**9+7 mod count += 1 1 count inf = float('inf') float('inf') inf count = 0 0 count ans = 0 0 ans pro = 1 1 pro ans += count count ans s = s.replace("BC", "D") s.replace("BC", "D") s count = 0 0 count
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
s = s.replace("BC", "D")
n = len(s)
for i in range (n):
  if s[i] == "A":
    count += 1
  elif s[i] == "D":
    ans += count
  else:
    count = 0
print(ans)

