s = input()
ans = 0
count = 0

for x in s.replace("BC", "Z"):
    if x == "A":
        count += 1
        continue
    elif x == "Z":
        ans += count
    else:
        count = 0
print(ans) s = input() s input() input ans = 0 ans 0 count = 0 count 0 for x in s.replace("BC", "Z"):
    if x == "A":
        count += 1
        continue
    elif x == "Z":
        ans += count
    else:
        count = 0 x s.replace("BC", "Z") s.replace s replace "BC" "Z" if x == "A":
        count += 1
        continue
    elif x == "Z":
        ans += count
    else:
        count = 0 x == "A" x "A" count += 1 count 1 continue elif x == "Z":
        ans += count
     x == "Z" x "Z" ans += count ans count count = 0 count 0 print(ans) print ans s = input() input() s ans += count count ans count = 0 0 count count = 0 0 count ans = 0 0 ans count += 1 1 count
s = input()
ans = 0
count = 0

for x in s.replace("BC", "Z"):
    if x == "A":
        count += 1
        continue
    elif x == "Z":
        ans += count
    else:
        count = 0
print(ans)
