import re

S = 'S' + input()
new_s = list(S.replace('BC', 'D'))


cnt = 0
A = 0
for i in range(len(new_s)):
    if new_s[i] == 'A':
        A += 1
    elif new_s[i] == 'D':
        cnt += A
    else:
        A = 0
print(cnt) import re re S = 'S' + input() S 'S' + input() 'S' input() input new_s = list(S.replace('BC', 'D')) new_s list(S.replace('BC', 'D')) list S.replace('BC', 'D') S.replace S replace 'BC' 'D' cnt = 0 cnt 0 A = 0 A 0 for i in range(len(new_s)):
    if new_s[i] == 'A':
        A += 1
    elif new_s[i] == 'D':
        cnt += A
    else:
        A = 0 i range(len(new_s)) range len(new_s) len new_s if new_s[i] == 'A':
        A += 1
    elif new_s[i] == 'D':
        cnt += A
    else:
        A = 0 new_s[i] == 'A' new_s[i] new_s i 'A' A += 1 A 1 elif new_s[i] == 'D':
        cnt += A
     new_s[i] == 'D' new_s[i] new_s i 'D' cnt += A cnt A A = 0 A 0 print(cnt) print cnt A += 1 1 A S = 'S' + input() 'S' + input() S new_s = list(S.replace('BC', 'D')) list(S.replace('BC', 'D')) new_s cnt = 0 0 cnt A = 0 0 A cnt += A A cnt A = 0 0 A
import re

S = 'S' + input()
new_s = list(S.replace('BC', 'D'))


cnt = 0
A = 0
for i in range(len(new_s)):
    if new_s[i] == 'A':
        A += 1
    elif new_s[i] == 'D':
        cnt += A
    else:
        A = 0
print(cnt)