from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
ans = 0
count = 0
i = 0
while i < len(s) - 1:
    if s[i]== 'A':
        count += 1
        i += 1
    elif s[i:i+2] == 'BC':
        ans += count
        i += 2
    else:
        count = 0
        i += 1
print(ans) from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heapify,heappop,heappush from queue import Queue,LifoQueue,PriorityQueue from copy import deepcopy from time import time import string string import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 def input() : return sys.stdin.readline().strip() input def INT()   : return int(input()) INT def MAP()   : return map(int,input().split()) MAP def LIST()  : return list(MAP()) LIST s = input() s input() input ans = 0 ans 0 count = 0 count 0 i = 0 i 0 while i < len(s) - 1:
    if s[i]== 'A':
        count += 1
        i += 1
    elif s[i:i+2] == 'BC':
        ans += count
        i += 2
    else:
        count = 0
        i += 1 i < len(s) - 1 i len(s) - 1 len(s) len s 1 if s[i]== 'A':
        count += 1
        i += 1
    elif s[i:i+2] == 'BC':
        ans += count
        i += 2
    else:
        count = 0
        i += 1 s[i]== 'A' s[i] s i 'A' count += 1 count 1 i += 1 i 1 elif s[i:i+2] == 'BC':
        ans += count
        i += 2
     s[i:i+2] == 'BC' s[i:i+2] s i:i+2 i i+2 i 2 'BC' ans += count ans count i += 2 i 2 count = 0 count 0 i += 1 i 1 print(ans) print ans def MAP()   : return map(int,input().split()) def MAP()   : return map(int,input().split()) MAP count += 1 1 count count = 0 0 count i += 1 1 i def LIST()  : return list(MAP()) def LIST()  : return list(MAP()) LIST s = input() input() s def INT()   : return int(input()) def INT()   : return int(input()) INT i += 2 2 i i += 1 1 i ans += count count ans ans = 0 0 ans count = 0 0 count def input() : return sys.stdin.readline().strip() def input() : return sys.stdin.readline().strip() input i = 0 0 i
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
ans = 0
count = 0
i = 0
while i < len(s) - 1:
    if s[i]== 'A':
        count += 1
        i += 1
    elif s[i:i+2] == 'BC':
        ans += count
        i += 2
    else:
        count = 0
        i += 1
print(ans)