s = input()
s = s.replace("BC", "X")

ans = 0
a_count = 0

for i in range(len(s)):
    if s[i] == "A":
        a_count += 1
    elif s[i] == "X":
        ans += a_count
    else:
        a_count = 0

print(ans) s = input() s input() input s = s.replace("BC", "X") s s.replace("BC", "X") s.replace s replace "BC" "X" ans = 0 ans 0 a_count = 0 a_count 0 for i in range(len(s)):
    if s[i] == "A":
        a_count += 1
    elif s[i] == "X":
        ans += a_count
    else:
        a_count = 0 i range(len(s)) range len(s) len s if s[i] == "A":
        a_count += 1
    elif s[i] == "X":
        ans += a_count
    else:
        a_count = 0 s[i] == "A" s[i] s i "A" a_count += 1 a_count 1 elif s[i] == "X":
        ans += a_count
     s[i] == "X" s[i] s i "X" ans += a_count ans a_count a_count = 0 a_count 0 print(ans) print ans a_count = 0 0 a_count ans = 0 0 ans a_count += 1 1 a_count ans += a_count a_count ans a_count = 0 0 a_count s = input() input() s s = s.replace("BC", "X") s.replace("BC", "X") s
s = input()
s = s.replace("BC", "X")

ans = 0
a_count = 0

for i in range(len(s)):
    if s[i] == "A":
        a_count += 1
    elif s[i] == "X":
        ans += a_count
    else:
        a_count = 0

print(ans)