s = raw_input()
count = 0
num = 0
i = 0
length = len(s)
while i < length:
	if s[i] == 'A':
		num += 1
		i += 1
	elif i+1 < len(s) and s[i] == 'B' and s[i+1] == 'C':
		count += num
		i += 2
	else:
		num = 0
		i += 1
print count s = raw_input() s raw_input() raw_input count = 0 count 0 num = 0 num 0 i = 0 i 0 length = len(s) length len(s) len s while i < length:
	if s[i] == 'A':
		num += 1
		i += 1
	elif i+1 < len(s) and s[i] == 'B' and s[i+1] == 'C':
		count += num
		i += 2
	else:
		num = 0
		i += 1 i < length i length if s[i] == 'A':
		num += 1
		i += 1
	elif i+1 < len(s) and s[i] == 'B' and s[i+1] == 'C':
		count += num
		i += 2
	else:
		num = 0
		i += 1 s[i] == 'A' s[i] s i 'A' num += 1 num 1 i += 1 i 1 elif i+1 < len(s) and s[i] == 'B' and s[i+1] == 'C':
		count += num
		i += 2
	 i+1 < len(s) and s[i] == 'B' and s[i+1] == 'C' i+1 < len(s) and s[i] == 'B' i+1 < len(s) i+1 i 1 len(s) len s s[i] == 'B' s[i] s i 'B' s[i+1] == 'C' s[i+1] s i+1 i 1 'C' count += num count num i += 2 i 2 num = 0 num 0 i += 1 i 1 print length = len(s) len(s) length count = 0 0 count i = 0 0 i i += 1 1 i num += 1 1 num i += 2 2 i count += num num count s = raw_input() raw_input() s i += 1 1 i num = 0 0 num num = 0 0 num
s = raw_input()
count = 0
num = 0
i = 0
length = len(s)
while i < length:
	if s[i] == 'A':
		num += 1
		i += 1
	elif i+1 < len(s) and s[i] == 'B' and s[i+1] == 'C':
		count += num
		i += 2
	else:
		num = 0
		i += 1
print count
