s = input()
s = s.replace("BC", "D")
N = len(s)
# print(s)
cnt = 0
ans = 0
for c in s:
    if c == "A":
        cnt += 1
    elif c == "D":
        ans += cnt
    else:
        cnt = 0
print(ans) s = input() s input() input s = s.replace("BC", "D") s s.replace("BC", "D") s.replace s replace "BC" "D" N = len(s) N len(s) len s cnt = 0 cnt 0 ans = 0 ans 0 for c in s:
    if c == "A":
        cnt += 1
    elif c == "D":
        ans += cnt
    else:
        cnt = 0 c s if c == "A":
        cnt += 1
    elif c == "D":
        ans += cnt
    else:
        cnt = 0 c == "A" c "A" cnt += 1 cnt 1 elif c == "D":
        ans += cnt
     c == "D" c "D" ans += cnt ans cnt cnt = 0 cnt 0 print(ans) print ans s = s.replace("BC", "D") s.replace("BC", "D") s ans = 0 0 ans N = len(s) len(s) N s = input() input() s cnt = 0 0 cnt cnt += 1 1 cnt cnt = 0 0 cnt ans += cnt cnt ans
s = input()
s = s.replace("BC", "D")
N = len(s)
# print(s)
cnt = 0
ans = 0
for c in s:
    if c == "A":
        cnt += 1
    elif c == "D":
        ans += cnt
    else:
        cnt = 0
print(ans)