s = input()
n = len(s)
i = 0
j = 0
ans = 0
while i < n:
    if s[i] == "A":
        j += 1
        i += 1
    elif i + 1 < n and s[i:i + 2] == "BC":
        ans += j
        i += 2
    else:
        j = 0
        i += 1
print(ans) s = input() s input() input n = len(s) n len(s) len s i = 0 i 0 j = 0 j 0 ans = 0 ans 0 while i < n:
    if s[i] == "A":
        j += 1
        i += 1
    elif i + 1 < n and s[i:i + 2] == "BC":
        ans += j
        i += 2
    else:
        j = 0
        i += 1 i < n i n if s[i] == "A":
        j += 1
        i += 1
    elif i + 1 < n and s[i:i + 2] == "BC":
        ans += j
        i += 2
    else:
        j = 0
        i += 1 s[i] == "A" s[i] s i "A" j += 1 j 1 i += 1 i 1 elif i + 1 < n and s[i:i + 2] == "BC":
        ans += j
        i += 2
     i + 1 < n and s[i:i + 2] == "BC" i + 1 < n i + 1 i 1 n s[i:i + 2] == "BC" s[i:i + 2] s i:i + 2 i i + 2 i 2 "BC" ans += j ans j i += 2 i 2 j = 0 j 0 i += 1 i 1 print(ans) print ans i = 0 0 i i += 1 1 i ans += j j ans j += 1 1 j j = 0 0 j j = 0 0 j s = input() input() s ans = 0 0 ans n = len(s) len(s) n i += 1 1 i i += 2 2 i
s = input()
n = len(s)
i = 0
j = 0
ans = 0
while i < n:
    if s[i] == "A":
        j += 1
        i += 1
    elif i + 1 < n and s[i:i + 2] == "BC":
        ans += j
        i += 2
    else:
        j = 0
        i += 1
print(ans)
