import re

s = input().replace('BC', 'X')

S = re.split('[BC]', s)
answer = 0

for i in S:
    tmp = 0
    for j in i:
        if j == 'A':
            tmp += 1
        elif j == 'X':
            answer += tmp

print(answer) import re re s = input().replace('BC', 'X') s input().replace('BC', 'X') ().replace () input replace 'BC' 'X' S = re.split('[BC]', s) S re.split('[BC]', s) re.split re split '[BC]' s answer = 0 answer 0 for i in S:
    tmp = 0
    for j in i:
        if j == 'A':
            tmp += 1
        elif j == 'X':
            answer += tmp i S tmp = 0 tmp 0 for j in i:
        if j == 'A':
            tmp += 1
        elif j == 'X':
            answer += tmp j i if j == 'A':
            tmp += 1
        elif j == 'X':
            answer += tmp j == 'A' j 'A' tmp += 1 tmp 1 elif j == 'X':
            answer += tmp j == 'X' j 'X' answer += tmp answer tmp print(answer) print answer answer += tmp tmp answer answer = 0 0 answer S = re.split('[BC]', s) re.split('[BC]', s) S tmp = 0 0 tmp s = input().replace('BC', 'X') input().replace('BC', 'X') s tmp += 1 1 tmp
import re

s = input().replace('BC', 'X')

S = re.split('[BC]', s)
answer = 0

for i in S:
    tmp = 0
    for j in i:
        if j == 'A':
            tmp += 1
        elif j == 'X':
            answer += tmp

print(answer)