#!/usr/bin/python3
# -*- coding:utf-8 -*-

import re

def main():
  s = input().strip()
  s = s.replace('BC', 'X')
  ans = 0
  for ax in re.split(r'[BC]+', s):
    inds = []
    for i in range(len(ax)):
      if ax[i] == 'A':
        inds.append(i)
    ans += sum([len(ax) - 1 - ind for ind in inds]) - sum(range(len(inds)))
  print(ans)

if __name__=='__main__':
  main()
 import re re def main():
  s = input().strip()
  s = s.replace('BC', 'X')
  ans = 0
  for ax in re.split(r'[BC]+', s):
    inds = []
    for i in range(len(ax)):
      if ax[i] == 'A':
        inds.append(i)
    ans += sum([len(ax) - 1 - ind for ind in inds]) - sum(range(len(inds)))
  print(ans) main s = input().strip() s input().strip() ().strip () input strip s = s.replace('BC', 'X') s s.replace('BC', 'X') s.replace s replace 'BC' 'X' ans = 0 ans 0 for ax in re.split(r'[BC]+', s):
    inds = []
    for i in range(len(ax)):
      if ax[i] == 'A':
        inds.append(i)
    ans += sum([len(ax) - 1 - ind for ind in inds]) - sum(range(len(inds)))
   ax re.split(r'[BC]+', s) re.split re split r'[BC]+' s inds = [] inds [] for i in range(len(ax)):
      if ax[i] == 'A':
        inds.append(i)
     i range(len(ax)) range len(ax) len ax if ax[i] == 'A':
        inds.append(i)
     ax[i] == 'A' ax[i] ax i 'A' inds.append(i) inds.append inds append i len(ax) - 1 - ind for ind in inds for ind in inds ind inds for ind in inds len(ax) - 1 - ind len(ax) - 1 len(ax) len ax 1 ind ans += sum([len(ax) - 1 - ind for ind in inds]) - sum(range(len(inds))) ans sum([len(ax) - 1 - ind for ind in inds]) - sum(range(len(inds))) sum([len(ax) - 1 - ind for ind in inds]) sum [len(ax) - 1 - ind for ind in inds] sum(range(len(inds))) sum range(len(inds)) range len(inds) len inds print(ans) print ans if __name__=='__main__':
  main() __name__=='__main__' __name__ '__main__' main() main def main():
  s = input().strip()
  s = s.replace('BC', 'X')
  ans = 0
  for ax in re.split(r'[BC]+', s):
    inds = []
    for i in range(len(ax)):
      if ax[i] == 'A':
        inds.append(i)
    ans += sum([len(ax) - 1 - ind for ind in inds]) - sum(range(len(inds)))
  print(ans) def main():
  s = input().strip()
  s = s.replace('BC', 'X')
  ans = 0
  for ax in re.split(r'[BC]+', s):
    inds = []
    for i in range(len(ax)):
      if ax[i] == 'A':
        inds.append(i)
    ans += sum([len(ax) - 1 - ind for ind in inds]) - sum(range(len(inds)))
  print(ans) main
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import re

def main():
  s = input().strip()
  s = s.replace('BC', 'X')
  ans = 0
  for ax in re.split(r'[BC]+', s):
    inds = []
    for i in range(len(ax)):
      if ax[i] == 'A':
        inds.append(i)
    ans += sum([len(ax) - 1 - ind for ind in inds]) - sum(range(len(inds)))
  print(ans)

if __name__=='__main__':
  main()

