s = input()
s = s.replace('BC','D')
A_count = 0
ans = 0

for i in s:
    if i == 'A':
        A_count += 1
    elif i == 'B' or i == 'C':
        A_count = 0
    else:
        ans += A_count
print(ans) s = input() s input() input s = s.replace('BC','D') s s.replace('BC','D') s.replace s replace 'BC' 'D' A_count = 0 A_count 0 ans = 0 ans 0 for i in s:
    if i == 'A':
        A_count += 1
    elif i == 'B' or i == 'C':
        A_count = 0
    else:
        ans += A_count i s if i == 'A':
        A_count += 1
    elif i == 'B' or i == 'C':
        A_count = 0
    else:
        ans += A_count i == 'A' i 'A' A_count += 1 A_count 1 elif i == 'B' or i == 'C':
        A_count = 0
     i == 'B' or i == 'C' i == 'B' i 'B' i == 'C' i 'C' A_count = 0 A_count 0 ans += A_count ans A_count print(ans) print ans A_count = 0 0 A_count A_count = 0 0 A_count A_count += 1 1 A_count ans = 0 0 ans s = input() input() s ans += A_count A_count ans s = s.replace('BC','D') s.replace('BC','D') s
s = input()
s = s.replace('BC','D')
A_count = 0
ans = 0

for i in s:
    if i == 'A':
        A_count += 1
    elif i == 'B' or i == 'C':
        A_count = 0
    else:
        ans += A_count
print(ans)