s=input().replace("BC","X").replace("B","Y").replace("C","Y")
a=False
ans=0
c=0
for i in "Y"+s+"Y":
	if i=="A":
		a=True
		c+=1
	if i=="X":
		if a:
			ans+=c
	if i=="Y":
		a=False
		c=0
print(ans) s=input().replace("BC","X").replace("B","Y").replace("C","Y") s input().replace("BC","X").replace("B","Y").replace("C","Y") ().replace("BC","X").replace("B","Y").replace ().replace("BC","X").replace("B","Y") ().replace("BC","X").replace ().replace("BC","X") ().replace () input replace "BC" "X" replace "B" "Y" replace "C" "Y" a=False a False ans=0 ans 0 c=0 c 0 for i in "Y"+s+"Y":
	if i=="A":
		a=True
		c+=1
	if i=="X":
		if a:
			ans+=c
	if i=="Y":
		a=False
		c=0 i "Y"+s+"Y" "Y"+s "Y" s "Y" if i=="A":
		a=True
		c+=1
	 i=="A" i "A" a=True a True c+=1 c 1 if i=="X":
		if a:
			ans+=c
	 i=="X" i "X" if a:
			ans+=c
	 a ans+=c ans c if i=="Y":
		a=False
		c=0 i=="Y" i "Y" a=False a False c=0 c 0 print(ans) print ans s=input().replace("BC","X").replace("B","Y").replace("C","Y") input().replace("BC","X").replace("B","Y").replace("C","Y") s a=False False a c=0 0 c c+=1 1 c ans+=c c ans ans=0 0 ans a=True True a a=False False a c=0 0 c
s=input().replace("BC","X").replace("B","Y").replace("C","Y")
a=False
ans=0
c=0
for i in "Y"+s+"Y":
	if i=="A":
		a=True
		c+=1
	if i=="X":
		if a:
			ans+=c
	if i=="Y":
		a=False
		c=0
print(ans)