s = input()
s = s.replace("BC","D")
a,ans = 0,0
#Dより前にあるB,C意外でつながったAの数をカウント
for i in s:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0
print(ans) s = input() s input() input s = s.replace("BC","D") s s.replace("BC","D") s.replace s replace "BC" "D" a,ans = 0,0 a 0 ans 0 for i in s:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0 i s if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0 i == "A" i "A" a += 1 a 1 elif i == "D":
        ans += a
     i == "D" i "D" ans += a ans a a = 0 a 0 print(ans) print ans s = s.replace("BC","D") s.replace("BC","D") s a,ans = 0,0 0 a a += 1 1 a a = 0 0 a s = input() input() s ans = 0,0 0 ans ans += a a ans
s = input()
s = s.replace("BC","D")
a,ans = 0,0
#Dより前にあるB,C意外でつながったAの数をカウント
for i in s:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0
print(ans)
