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