s = input()

s = s.replace("BC", "D")

ans = 0
a_cnt = 0
for e in s:
    if e == "A":
        a_cnt += 1

    elif e == "D":
        ans += a_cnt

    else:
        a_cnt = 0

print(ans) s = input() s input() input s = s.replace("BC", "D") s s.replace("BC", "D") s.replace s replace "BC" "D" ans = 0 ans 0 a_cnt = 0 a_cnt 0 for e in s:
    if e == "A":
        a_cnt += 1

    elif e == "D":
        ans += a_cnt

    else:
        a_cnt = 0 e s if e == "A":
        a_cnt += 1

    elif e == "D":
        ans += a_cnt

    else:
        a_cnt = 0 e == "A" e "A" a_cnt += 1 a_cnt 1 elif e == "D":
        ans += a_cnt

     e == "D" e "D" ans += a_cnt ans a_cnt a_cnt = 0 a_cnt 0 print(ans) print ans ans = 0 0 ans s = input() input() s s = s.replace("BC", "D") s.replace("BC", "D") s a_cnt = 0 0 a_cnt a_cnt = 0 0 a_cnt ans += a_cnt a_cnt ans a_cnt += 1 1 a_cnt
s = input()

s = s.replace("BC", "D")

ans = 0
a_cnt = 0
for e in s:
    if e == "A":
        a_cnt += 1

    elif e == "D":
        ans += a_cnt

    else:
        a_cnt = 0

print(ans)
