s = input()
cnt = 0
ans = 0
flag = False
for i in range(len(s) - 1):
    if flag:
        flag = False
        continue
    if s[i: i + 2] == 'BC':
        ans += cnt
        flag = True
    elif s[i] == 'A':
        cnt += 1
    else:
        cnt = 0
print(ans) s = input() s input() input cnt = 0 cnt 0 ans = 0 ans 0 flag = False flag False for i in range(len(s) - 1):
    if flag:
        flag = False
        continue
    if s[i: i + 2] == 'BC':
        ans += cnt
        flag = True
    elif s[i] == 'A':
        cnt += 1
    else:
        cnt = 0 i range(len(s) - 1) range len(s) - 1 len(s) len s 1 if flag:
        flag = False
        continue
     flag flag = False flag False continue if s[i: i + 2] == 'BC':
        ans += cnt
        flag = True
    elif s[i] == 'A':
        cnt += 1
    else:
        cnt = 0 s[i: i + 2] == 'BC' s[i: i + 2] s i: i + 2 i i + 2 i 2 'BC' ans += cnt ans cnt flag = True flag True elif s[i] == 'A':
        cnt += 1
     s[i] == 'A' s[i] s i 'A' cnt += 1 cnt 1 cnt = 0 cnt 0 print(ans) print ans cnt = 0 0 cnt flag = False False flag cnt = 0 0 cnt ans += cnt cnt ans s = input() input() s ans = 0 0 ans flag = False False flag flag = True True flag cnt += 1 1 cnt
s = input()
cnt = 0
ans = 0
flag = False
for i in range(len(s) - 1):
    if flag:
        flag = False
        continue
    if s[i: i + 2] == 'BC':
        ans += cnt
        flag = True
    elif s[i] == 'A':
        cnt += 1
    else:
        cnt = 0
print(ans)