s = input().replace('BC', 'D')

a = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'D':
        ans += a
    else:
        a = 0

print(ans) s = input().replace('BC', 'D') s input().replace('BC', 'D') ().replace () input replace 'BC' 'D' a = 0 a 0 ans = 0 ans 0 for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'D':
        ans += a
    else:
        a = 0 i range(len(s)) range len(s) len s if s[i] == 'A':
        a += 1
    elif s[i] == 'D':
        ans += a
    else:
        a = 0 s[i] == 'A' s[i] s i 'A' a += 1 a 1 elif s[i] == 'D':
        ans += a
     s[i] == 'D' s[i] s i 'D' ans += a ans a a = 0 a 0 print(ans) print ans s = input().replace('BC', 'D') input().replace('BC', 'D') s a += 1 1 a a = 0 0 a ans = 0 0 ans a = 0 0 a ans += a a ans
s = input().replace('BC', 'D')

a = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'A':
        a += 1
    elif s[i] == 'D':
        ans += a
    else:
        a = 0

print(ans)