s = input()

s = s.replace('BC', 'V')

ans = 0
cnt = 0
flag = False

for i in range(len(s)):
    if s[i] == 'A':
        flag = True
        cnt += 1
    elif flag and s[i] == 'V':
        ans += cnt
    else:
        flag = False
        cnt = 0

print(ans) s = input() s input() input s = s.replace('BC', 'V') s s.replace('BC', 'V') s.replace s replace 'BC' 'V' ans = 0 ans 0 cnt = 0 cnt 0 flag = False flag False for i in range(len(s)):
    if s[i] == 'A':
        flag = True
        cnt += 1
    elif flag and s[i] == 'V':
        ans += cnt
    else:
        flag = False
        cnt = 0 i range(len(s)) range len(s) len s if s[i] == 'A':
        flag = True
        cnt += 1
    elif flag and s[i] == 'V':
        ans += cnt
    else:
        flag = False
        cnt = 0 s[i] == 'A' s[i] s i 'A' flag = True flag True cnt += 1 cnt 1 elif flag and s[i] == 'V':
        ans += cnt
     flag and s[i] == 'V' flag s[i] == 'V' s[i] s i 'V' ans += cnt ans cnt flag = False flag False cnt = 0 cnt 0 print(ans) print ans flag = False False flag ans += cnt cnt ans ans = 0 0 ans flag = True True flag flag = False False flag cnt += 1 1 cnt s = input() input() s cnt = 0 0 cnt s = s.replace('BC', 'V') s.replace('BC', 'V') s cnt = 0 0 cnt
s = input()

s = s.replace('BC', 'V')

ans = 0
cnt = 0
flag = False

for i in range(len(s)):
    if s[i] == 'A':
        flag = True
        cnt += 1
    elif flag and s[i] == 'V':
        ans += cnt
    else:
        flag = False
        cnt = 0

print(ans)
