s = input().replace("BC", "D")

ans = 0
cnt = 0
for i in s[::-1]:
    if i == "D":
        cnt += 1
    elif i == "A":
        ans += cnt
    else:
        cnt = 0



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

ans = 0
cnt = 0
for i in s[::-1]:
    if i == "D":
        cnt += 1
    elif i == "A":
        ans += cnt
    else:
        cnt = 0



print(ans)