s = input().replace('BC', 'X')
cnt_a = 0
ans = 0
for c in s:
    if c == 'A':
        cnt_a += 1
    if c == 'X':
        ans += cnt_a
    if c in 'BC':
        cnt_a = 0
print(ans) s = input().replace('BC', 'X') s input().replace('BC', 'X') ().replace () input replace 'BC' 'X' cnt_a = 0 cnt_a 0 ans = 0 ans 0 for c in s:
    if c == 'A':
        cnt_a += 1
    if c == 'X':
        ans += cnt_a
    if c in 'BC':
        cnt_a = 0 c s if c == 'A':
        cnt_a += 1
     c == 'A' c 'A' cnt_a += 1 cnt_a 1 if c == 'X':
        ans += cnt_a
     c == 'X' c 'X' ans += cnt_a ans cnt_a if c in 'BC':
        cnt_a = 0 c in 'BC' c 'BC' cnt_a = 0 cnt_a 0 print(ans) print ans cnt_a += 1 1 cnt_a ans = 0 0 ans cnt_a = 0 0 cnt_a ans += cnt_a cnt_a ans cnt_a = 0 0 cnt_a s = input().replace('BC', 'X') input().replace('BC', 'X') s
s = input().replace('BC', 'X')
cnt_a = 0
ans = 0
for c in s:
    if c == 'A':
        cnt_a += 1
    if c == 'X':
        ans += cnt_a
    if c in 'BC':
        cnt_a = 0
print(ans)
