s = input()
s = s.replace("BC","D")
ans = 0
a = 0
for k in range(len(s)):
    if s[k] == "A":
        a += 1
    elif s[k] == "D":
        ans += a
    else:
        a = 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 = 0 a 0 for k in range(len(s)):
    if s[k] == "A":
        a += 1
    elif s[k] == "D":
        ans += a
    else:
        a = 0 k range(len(s)) range len(s) len s if s[k] == "A":
        a += 1
    elif s[k] == "D":
        ans += a
    else:
        a = 0 s[k] == "A" s[k] s k "A" a += 1 a 1 elif s[k] == "D":
        ans += a
     s[k] == "D" s[k] s k "D" ans += a ans a a = 0 a 0 print(ans) print ans a = 0 0 a s = s.replace("BC","D") s.replace("BC","D") s a = 0 0 a a += 1 1 a s = input() input() s ans = 0 0 ans ans += a a ans
s = input()
s = s.replace("BC","D")
ans = 0
a = 0
for k in range(len(s)):
    if s[k] == "A":
        a += 1
    elif s[k] == "D":
        ans += a
    else:
        a = 0
print(ans)
