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

A=[]
word=""
for i in s:
    if i=="A" or i=="D":word +=i
    else:A.append(word);word=""

cnt=0
for i in A:
    a=0
    for j in i:
        if j=="A":a +=1
        else:cnt +=a

print(cnt) s=input().replace("BC","D")+"E" s input().replace("BC","D")+"E" input().replace("BC","D") ().replace () input replace "BC" "D" "E" A=[] A [] word="" word "" for i in s:
    if i=="A" or i=="D":word +=i
    else:A.append(word);word="" i s if i=="A" or i=="D":word +=i
    else:A.append(word);word="" i=="A" or i=="D" i=="A" i "A" i=="D" i "D" cnt=0 cnt 0 for i in A:
    a=0
    for j in i:
        if j=="A":a +=1
        else:cnt +=a i A a=0 a 0 for j in i:
        if j=="A":a +=1
        else:cnt +=a j i if j=="A":a +=1
        else:cnt +=a j=="A" j "A" print(cnt) print cnt word="" "" word s=input().replace("BC","D")+"E" input().replace("BC","D")+"E" s a=0 0 a cnt=0 0 cnt A=[] [] A
s=input().replace("BC","D")+"E"

A=[]
word=""
for i in s:
    if i=="A" or i=="D":word +=i
    else:A.append(word);word=""

cnt=0
for i in A:
    a=0
    for j in i:
        if j=="A":a +=1
        else:cnt +=a

print(cnt)