import sys
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

S = readline().rstrip()
S = S.replace('BC', '#')

tmp = 0
ans = 0
for i in range(len(S)-1,-1,-1):
	if S[i] == "#":
		tmp += 1
	elif S[i] == "A":
		ans += tmp
	else:
		tmp = 0
print(ans) import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines S = readline().rstrip() S readline().rstrip() ().rstrip () readline rstrip S = S.replace('BC', '#') S S.replace('BC', '#') S.replace S replace 'BC' '#' tmp = 0 tmp 0 ans = 0 ans 0 for i in range(len(S)-1,-1,-1):
	if S[i] == "#":
		tmp += 1
	elif S[i] == "A":
		ans += tmp
	else:
		tmp = 0 i range(len(S)-1,-1,-1) range len(S)-1 len(S) len S 1 -1 -1 if S[i] == "#":
		tmp += 1
	elif S[i] == "A":
		ans += tmp
	else:
		tmp = 0 S[i] == "#" S[i] S i "#" tmp += 1 tmp 1 elif S[i] == "A":
		ans += tmp
	 S[i] == "A" S[i] S i "A" ans += tmp ans tmp tmp = 0 tmp 0 print(ans) print ans readline = sys.stdin.readline sys.stdin.readline readline ans = 0 0 ans read = sys.stdin.buffer.read sys.stdin.buffer.read read tmp = 0 0 tmp S = S.replace('BC', '#') S.replace('BC', '#') S tmp = 0 0 tmp ans += tmp tmp ans readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines S = readline().rstrip() readline().rstrip() S tmp += 1 1 tmp
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines

S = readline().rstrip()
S = S.replace('BC', '#')

tmp = 0
ans = 0
for i in range(len(S)-1,-1,-1):
	if S[i] == "#":
		tmp += 1
	elif S[i] == "A":
		ans += tmp
	else:
		tmp = 0
print(ans)
