s = input()

aaa = 0
ans = 0
i = 0
while i < len(s) - 1:
    if s[i] == 'A':
        aaa += 1
    elif s[i:i+2] == 'BC':
        ans += aaa
        i += 1
    else:
        aaa = 0
    i += 1
print(ans) s = input() s input() input aaa = 0 aaa 0 ans = 0 ans 0 i = 0 i 0 while i < len(s) - 1:
    if s[i] == 'A':
        aaa += 1
    elif s[i:i+2] == 'BC':
        ans += aaa
        i += 1
    else:
        aaa = 0
    i += 1 i < len(s) - 1 i len(s) - 1 len(s) len s 1 if s[i] == 'A':
        aaa += 1
    elif s[i:i+2] == 'BC':
        ans += aaa
        i += 1
    else:
        aaa = 0
     s[i] == 'A' s[i] s i 'A' aaa += 1 aaa 1 elif s[i:i+2] == 'BC':
        ans += aaa
        i += 1
     s[i:i+2] == 'BC' s[i:i+2] s i:i+2 i i+2 i 2 'BC' ans += aaa ans aaa i += 1 i 1 aaa = 0 aaa 0 i += 1 i 1 print(ans) print ans aaa += 1 1 aaa i = 0 0 i i += 1 1 i i += 1 1 i s = input() input() s ans = 0 0 ans aaa = 0 0 aaa ans += aaa aaa ans aaa = 0 0 aaa
s = input()

aaa = 0
ans = 0
i = 0
while i < len(s) - 1:
    if s[i] == 'A':
        aaa += 1
    elif s[i:i+2] == 'BC':
        ans += aaa
        i += 1
    else:
        aaa = 0
    i += 1
print(ans)
