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