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