s = str(input())
s = s.replace('BC', 'D')
n = len(s)

ans = 0
cnt = 0
for i in range(n):
    if s[i] == 'A':
        cnt += 1
    if s[i] == 'D':
        ans += cnt
    if s[i] == 'B' or s[i] == 'C':
        cnt = 0
print(ans) s = str(input()) s str(input()) str input() input s = s.replace('BC', 'D') s s.replace('BC', 'D') s.replace s replace 'BC' 'D' n = len(s) n len(s) len s ans = 0 ans 0 cnt = 0 cnt 0 for i in range(n):
    if s[i] == 'A':
        cnt += 1
    if s[i] == 'D':
        ans += cnt
    if s[i] == 'B' or s[i] == 'C':
        cnt = 0 i range(n) range n if s[i] == 'A':
        cnt += 1
     s[i] == 'A' s[i] s i 'A' cnt += 1 cnt 1 if s[i] == 'D':
        ans += cnt
     s[i] == 'D' s[i] s i 'D' ans += cnt ans cnt if s[i] == 'B' or s[i] == 'C':
        cnt = 0 s[i] == 'B' or s[i] == 'C' s[i] == 'B' s[i] s i 'B' s[i] == 'C' s[i] s i 'C' cnt = 0 cnt 0 print(ans) print ans ans = 0 0 ans cnt += 1 1 cnt s = s.replace('BC', 'D') s.replace('BC', 'D') s ans += cnt cnt ans n = len(s) len(s) n s = str(input()) str(input()) s cnt = 0 0 cnt cnt = 0 0 cnt
s = str(input())
s = s.replace('BC', 'D')
n = len(s)

ans = 0
cnt = 0
for i in range(n):
    if s[i] == 'A':
        cnt += 1
    if s[i] == 'D':
        ans += cnt
    if s[i] == 'B' or s[i] == 'C':
        cnt = 0
print(ans)