s = input()
n = len(s)

i = 0
numA = 0
res = 0
while i < n-1:
    if s[i] == 'A':
        numA += 1
    elif s[i] == 'B' and s[i+1] == 'C':
        res += numA
        i += 1
    else:
        numA = 0
    i += 1
print(res) s = input() s input() input n = len(s) n len(s) len s i = 0 i 0 numA = 0 numA 0 res = 0 res 0 while i < n-1:
    if s[i] == 'A':
        numA += 1
    elif s[i] == 'B' and s[i+1] == 'C':
        res += numA
        i += 1
    else:
        numA = 0
    i += 1 i < n-1 i n-1 n 1 if s[i] == 'A':
        numA += 1
    elif s[i] == 'B' and s[i+1] == 'C':
        res += numA
        i += 1
    else:
        numA = 0
     s[i] == 'A' s[i] s i 'A' numA += 1 numA 1 elif s[i] == 'B' and s[i+1] == 'C':
        res += numA
        i += 1
     s[i] == 'B' and s[i+1] == 'C' s[i] == 'B' s[i] s i 'B' s[i+1] == 'C' s[i+1] s i+1 i 1 'C' res += numA res numA i += 1 i 1 numA = 0 numA 0 i += 1 i 1 print(res) print res i += 1 1 i res = 0 0 res numA += 1 1 numA i = 0 0 i i += 1 1 i res += numA numA res s = input() input() s numA = 0 0 numA n = len(s) len(s) n numA = 0 0 numA
s = input()
n = len(s)

i = 0
numA = 0
res = 0
while i < n-1:
    if s[i] == 'A':
        numA += 1
    elif s[i] == 'B' and s[i+1] == 'C':
        res += numA
        i += 1
    else:
        numA = 0
    i += 1
print(res)
