s = input()
s = s.replace('BC', 'T')
a_count = 0
ans = 0
for c in s:
    if c == 'A':
        a_count += 1
    elif c == 'T':
        ans += a_count
    else:
        a_count = 0
print(ans) s = input() s input() input s = s.replace('BC', 'T') s s.replace('BC', 'T') s.replace s replace 'BC' 'T' a_count = 0 a_count 0 ans = 0 ans 0 for c in s:
    if c == 'A':
        a_count += 1
    elif c == 'T':
        ans += a_count
    else:
        a_count = 0 c s if c == 'A':
        a_count += 1
    elif c == 'T':
        ans += a_count
    else:
        a_count = 0 c == 'A' c 'A' a_count += 1 a_count 1 elif c == 'T':
        ans += a_count
     c == 'T' c 'T' ans += a_count ans a_count a_count = 0 a_count 0 print(ans) print ans ans = 0 0 ans a_count = 0 0 a_count s = input() input() s a_count += 1 1 a_count s = s.replace('BC', 'T') s.replace('BC', 'T') s a_count = 0 0 a_count ans += a_count a_count ans
s = input()
s = s.replace('BC', 'T')
a_count = 0
ans = 0
for c in s:
    if c == 'A':
        a_count += 1
    elif c == 'T':
        ans += a_count
    else:
        a_count = 0
print(ans)
