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

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

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