s = input().replace('BC','D')
d = 0
ans = 0
for c in s[-1::-1]:
    if c == 'D':
        d += 1
    elif c == 'A':
        ans += d
    else:
        d = 0
print(ans) s = input().replace('BC','D') s input().replace('BC','D') ().replace () input replace 'BC' 'D' d = 0 d 0 ans = 0 ans 0 for c in s[-1::-1]:
    if c == 'D':
        d += 1
    elif c == 'A':
        ans += d
    else:
        d = 0 c s[-1::-1] s -1::-1 -1 -1 if c == 'D':
        d += 1
    elif c == 'A':
        ans += d
    else:
        d = 0 c == 'D' c 'D' d += 1 d 1 elif c == 'A':
        ans += d
     c == 'A' c 'A' ans += d ans d d = 0 d 0 print(ans) print ans d += 1 1 d ans += d d ans d = 0 0 d s = input().replace('BC','D') input().replace('BC','D') s d = 0 0 d ans = 0 0 ans
s = input().replace('BC','D')
d = 0
ans = 0
for c in s[-1::-1]:
    if c == 'D':
        d += 1
    elif c == 'A':
        ans += d
    else:
        d = 0
print(ans)