s = input()

tmp = ""
cnt = 0
ans = 0
flag = False  # skip用
for i in range(0, len(s) - 1):
    if flag:
        flag = False
        continue
    if s[i] == "A":
        cnt += 1
    elif s[i] + s[i + 1] == "BC":
        ans += cnt
        flag = True
    else:
        cnt = 0

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

tmp = ""
cnt = 0
ans = 0
flag = False  # skip用
for i in range(0, len(s) - 1):
    if flag:
        flag = False
        continue
    if s[i] == "A":
        cnt += 1
    elif s[i] + s[i + 1] == "BC":
        ans += cnt
        flag = True
    else:
        cnt = 0

print(ans)