s = input().replace('BC', 'D')
s = s.replace('B', 'C')
l = [x for x in s.split(sep='C') if x != '']
ans = 0
for subs in l:
    numA = 0
    for c in subs:
        if c == 'A':
            numA += 1
        elif c == 'D':
            ans += numA

print(ans) s = input().replace('BC', 'D') s input().replace('BC', 'D') ().replace () input replace 'BC' 'D' s = s.replace('B', 'C') s s.replace('B', 'C') s.replace s replace 'B' 'C' x for x in s.split(sep='C') if x != '' for x in s.split(sep='C') if x != '' x s.split(sep='C') s.split s split sep='C' sep 'C' x != '' x '' if x != '' x l = [x for x in s.split(sep='C') if x != ''] l [x for x in s.split(sep='C') if x != ''] ans = 0 ans 0 for subs in l:
    numA = 0
    for c in subs:
        if c == 'A':
            numA += 1
        elif c == 'D':
            ans += numA subs l numA = 0 numA 0 for c in subs:
        if c == 'A':
            numA += 1
        elif c == 'D':
            ans += numA c subs if c == 'A':
            numA += 1
        elif c == 'D':
            ans += numA c == 'A' c 'A' numA += 1 numA 1 elif c == 'D':
            ans += numA c == 'D' c 'D' ans += numA ans numA print(ans) print ans numA = 0 0 numA numA += 1 1 numA s = input().replace('BC', 'D') input().replace('BC', 'D') s ans = 0 0 ans ans += numA numA ans s = s.replace('B', 'C') s.replace('B', 'C') s l = [x for x in s.split(sep='C') if x != ''] [x for x in s.split(sep='C') if x != ''] l
s = input().replace('BC', 'D')
s = s.replace('B', 'C')
l = [x for x in s.split(sep='C') if x != '']
ans = 0
for subs in l:
    numA = 0
    for c in subs:
        if c == 'A':
            numA += 1
        elif c == 'D':
            ans += numA

print(ans)