s = input()
s = s.replace("BC", "X")
cnt, ans = 0, 0
for i in s:
    if i == "A":
        cnt += 1
    elif i == "X":
        ans += cnt
    else:
        cnt = 0
print(ans) s = input() s input() input s = s.replace("BC", "X") s s.replace("BC", "X") s.replace s replace "BC" "X" cnt, ans = 0, 0 cnt 0 ans 0 for i in s:
    if i == "A":
        cnt += 1
    elif i == "X":
        ans += cnt
    else:
        cnt = 0 i s if i == "A":
        cnt += 1
    elif i == "X":
        ans += cnt
    else:
        cnt = 0 i == "A" i "A" cnt += 1 cnt 1 elif i == "X":
        ans += cnt
     i == "X" i "X" ans += cnt ans cnt cnt = 0 cnt 0 print(ans) print ans s = input() input() s cnt, ans = 0, 0 0 cnt s = s.replace("BC", "X") s.replace("BC", "X") s ans = 0, 0 0 ans cnt += 1 1 cnt ans += cnt cnt ans cnt = 0 0 cnt
s = input()
s = s.replace("BC", "X")
cnt, ans = 0, 0
for i in s:
    if i == "A":
        cnt += 1
    elif i == "X":
        ans += cnt
    else:
        cnt = 0
print(ans)