s = input().replace('BC', 'D')
 
acc = 0
ans = 0
for c in s:
    if c == 'B' or c == 'C':
        acc = 0
        continue
    elif c == 'A':
        acc += 1
    else:
        ans += acc
print(ans) s = input().replace('BC', 'D') s input().replace('BC', 'D') ().replace () input replace 'BC' 'D' acc = 0 acc 0 ans = 0 ans 0 for c in s:
    if c == 'B' or c == 'C':
        acc = 0
        continue
    elif c == 'A':
        acc += 1
    else:
        ans += acc c s if c == 'B' or c == 'C':
        acc = 0
        continue
    elif c == 'A':
        acc += 1
    else:
        ans += acc c == 'B' or c == 'C' c == 'B' c 'B' c == 'C' c 'C' acc = 0 acc 0 continue elif c == 'A':
        acc += 1
     c == 'A' c 'A' acc += 1 acc 1 ans += acc ans acc print(ans) print ans ans = 0 0 ans acc += 1 1 acc acc = 0 0 acc ans += acc acc ans s = input().replace('BC', 'D') input().replace('BC', 'D') s acc = 0 0 acc
s = input().replace('BC', 'D')
 
acc = 0
ans = 0
for c in s:
    if c == 'B' or c == 'C':
        acc = 0
        continue
    elif c == 'A':
        acc += 1
    else:
        ans += acc
print(ans)