s = str(input())
s = s.replace('BC', 'D')
#print(s)
S = []
temp = []
for c in s:
    if c == 'A' or c == 'D':
        temp.append(c)
    else:
        if temp:
            S.append(temp)
            temp = []
else:
    if temp:
        S.append(temp)
#print(S)
ans = 0
for s in S:
    cnt = 0
    for j in range(len(s)):
        if s[j] == 'A':
            cnt += 1
        else:
            ans += cnt
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' S = [] S [] temp = [] temp [] for c in s:
    if c == 'A' or c == 'D':
        temp.append(c)
    else:
        if temp:
            S.append(temp)
            temp = []
else:
    if temp:
        S.append(temp)
#print(S) c s if c == 'A' or c == 'D':
        temp.append(c)
    else:
        if temp:
            S.append(temp)
            temp = [] c == 'A' or c == 'D' c == 'A' c 'A' c == 'D' c 'D' temp.append(c) temp.append temp append c if temp:
            S.append(temp)
            temp = [] temp S.append(temp) S.append S append temp temp = [] temp [] if temp:
        S.append(temp)
#print(S) temp S.append(temp) S.append S append temp ans = 0 ans 0 for s in S:
    cnt = 0
    for j in range(len(s)):
        if s[j] == 'A':
            cnt += 1
        else:
            ans += cnt s S cnt = 0 cnt 0 for j in range(len(s)):
        if s[j] == 'A':
            cnt += 1
        else:
            ans += cnt j range(len(s)) range len(s) len s if s[j] == 'A':
            cnt += 1
        else:
            ans += cnt s[j] == 'A' s[j] s j 'A' cnt += 1 cnt 1 ans += cnt ans cnt print(ans) print ans temp = [] [] temp cnt = 0 0 cnt ans += cnt cnt ans s = str(input()) str(input()) s ans = 0 0 ans cnt += 1 1 cnt s = s.replace('BC', 'D') s.replace('BC', 'D') s S = [] [] S temp = [] [] temp
s = str(input())
s = s.replace('BC', 'D')
#print(s)
S = []
temp = []
for c in s:
    if c == 'A' or c == 'D':
        temp.append(c)
    else:
        if temp:
            S.append(temp)
            temp = []
else:
    if temp:
        S.append(temp)
#print(S)
ans = 0
for s in S:
    cnt = 0
    for j in range(len(s)):
        if s[j] == 'A':
            cnt += 1
        else:
            ans += cnt
print(ans)
