S = input()
newS = S.replace("BC","D")
A_count = 0
ans = 0
for i in range(len(newS)):
    if newS[i] == "A":
        A_count += 1
    elif newS[i] == "D":
        ans += A_count
    else:
        A_count = 0
print(ans) S = input() S input() input newS = S.replace("BC","D") newS S.replace("BC","D") S.replace S replace "BC" "D" A_count = 0 A_count 0 ans = 0 ans 0 for i in range(len(newS)):
    if newS[i] == "A":
        A_count += 1
    elif newS[i] == "D":
        ans += A_count
    else:
        A_count = 0 i range(len(newS)) range len(newS) len newS if newS[i] == "A":
        A_count += 1
    elif newS[i] == "D":
        ans += A_count
    else:
        A_count = 0 newS[i] == "A" newS[i] newS i "A" A_count += 1 A_count 1 elif newS[i] == "D":
        ans += A_count
     newS[i] == "D" newS[i] newS i "D" ans += A_count ans A_count A_count = 0 A_count 0 print(ans) print ans newS = S.replace("BC","D") S.replace("BC","D") newS A_count = 0 0 A_count ans = 0 0 ans A_count = 0 0 A_count S = input() input() S A_count += 1 1 A_count ans += A_count A_count ans
S = input()
newS = S.replace("BC","D")
A_count = 0
ans = 0
for i in range(len(newS)):
    if newS[i] == "A":
        A_count += 1
    elif newS[i] == "D":
        ans += A_count
    else:
        A_count = 0
print(ans)