import sys
readline = sys.stdin.readline

S = readline().rstrip()
S = S.replace("BC","X")
S = S.replace("B",".").replace("C",".")
arr = S.split(".")
ans = 0
for a in arr:
  cnt = 0
  for i in range(len(a)):
    if a[i] == "X":
      ans += (i - cnt)
      cnt += 1
  
print(ans) import sys sys readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline S = readline().rstrip() S readline().rstrip() ().rstrip () readline rstrip S = S.replace("BC","X") S S.replace("BC","X") S.replace S replace "BC" "X" S = S.replace("B",".").replace("C",".") S S.replace("B",".").replace("C",".") S.replace("B",".").replace S.replace("B",".") S.replace S replace "B" "." replace "C" "." arr = S.split(".") arr S.split(".") S.split S split "." ans = 0 ans 0 for a in arr:
  cnt = 0
  for i in range(len(a)):
    if a[i] == "X":
      ans += (i - cnt)
      cnt += 1
   a arr cnt = 0 cnt 0 for i in range(len(a)):
    if a[i] == "X":
      ans += (i - cnt)
      cnt += 1
   i range(len(a)) range len(a) len a if a[i] == "X":
      ans += (i - cnt)
      cnt += 1
   a[i] == "X" a[i] a i "X" ans += (i - cnt) ans i - cnt i cnt cnt += 1 cnt 1 print(ans) print ans cnt += 1 1 cnt S = S.replace("B",".").replace("C",".") S.replace("B",".").replace("C",".") S cnt = 0 0 cnt readline = sys.stdin.readline sys.stdin.readline readline ans += (i - cnt) i - cnt ans ans = 0 0 ans arr = S.split(".") S.split(".") arr S = readline().rstrip() readline().rstrip() S S = S.replace("BC","X") S.replace("BC","X") S
import sys
readline = sys.stdin.readline

S = readline().rstrip()
S = S.replace("BC","X")
S = S.replace("B",".").replace("C",".")
arr = S.split(".")
ans = 0
for a in arr:
  cnt = 0
  for i in range(len(a)):
    if a[i] == "X":
      ans += (i - cnt)
      cnt += 1
  
print(ans)