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

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

print(sum(ans))