s=input()
s=s.replace("BC","Z")
#print(s)

a=0
b=0
for i in s:
    if i=="A":a+=1
    elif i=="Z":b+=a
    else:a=0
print(b) s=input() s input() input s=s.replace("BC","Z") s s.replace("BC","Z") s.replace s replace "BC" "Z" a=0 a 0 b=0 b 0 for i in s:
    if i=="A":a+=1
    elif i=="Z":b+=a
    else:a=0 i s if i=="A":a+=1
    elif i=="Z":b+=a
    else:a=0 i=="A" i "A" elif i=="Z":b+=a
     i=="Z" i "Z" print(b) print b s=s.replace("BC","Z") s.replace("BC","Z") s b=0 0 b s=input() input() s a=0 0 a
s=input()
s=s.replace("BC","Z")
#print(s)

a=0
b=0
for i in s:
    if i=="A":a+=1
    elif i=="Z":b+=a
    else:a=0
print(b)