s = input()
n = len(s)
ans = 0
cntA = 0
for i in range(n-1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i+2] == 'BC':
        ans += cntA
    elif i > 0 and s[i-1: i+1] == 'BC':
        continue
    else:
        cntA = 0

print(ans) s = input() s input() input n = len(s) n len(s) len s ans = 0 ans 0 cntA = 0 cntA 0 for i in range(n-1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i+2] == 'BC':
        ans += cntA
    elif i > 0 and s[i-1: i+1] == 'BC':
        continue
    else:
        cntA = 0 i range(n-1) range n-1 n 1 if s[i] == 'A':
        cntA += 1
    elif s[i: i+2] == 'BC':
        ans += cntA
    elif i > 0 and s[i-1: i+1] == 'BC':
        continue
    else:
        cntA = 0 s[i] == 'A' s[i] s i 'A' cntA += 1 cntA 1 elif s[i: i+2] == 'BC':
        ans += cntA
     s[i: i+2] == 'BC' s[i: i+2] s i: i+2 i i+2 i 2 'BC' ans += cntA ans cntA elif i > 0 and s[i-1: i+1] == 'BC':
        continue
     i > 0 and s[i-1: i+1] == 'BC' i > 0 i 0 s[i-1: i+1] == 'BC' s[i-1: i+1] s i-1: i+1 i-1 i 1 i+1 i 1 'BC' continue cntA = 0 cntA 0 print(ans) print ans s = input() input() s cntA = 0 0 cntA cntA = 0 0 cntA ans += cntA cntA ans cntA += 1 1 cntA ans = 0 0 ans n = len(s) len(s) n
s = input()
n = len(s)
ans = 0
cntA = 0
for i in range(n-1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i+2] == 'BC':
        ans += cntA
    elif i > 0 and s[i-1: i+1] == 'BC':
        continue
    else:
        cntA = 0

print(ans)
