s = list(input())
n = len(s)
ans = 0
c = 0
i = 0
while i < n-1:
    if s[i] == "B" and s[i+1] == "C":
        ans += c
        i += 1
    elif s[i] == "A":
        c += 1
    else:
        c = 0
    i += 1
print(ans) s = list(input()) s list(input()) list input() input n = len(s) n len(s) len s ans = 0 ans 0 c = 0 c 0 i = 0 i 0 while i < n-1:
    if s[i] == "B" and s[i+1] == "C":
        ans += c
        i += 1
    elif s[i] == "A":
        c += 1
    else:
        c = 0
    i += 1 i < n-1 i n-1 n 1 if s[i] == "B" and s[i+1] == "C":
        ans += c
        i += 1
    elif s[i] == "A":
        c += 1
    else:
        c = 0
     s[i] == "B" and s[i+1] == "C" s[i] == "B" s[i] s i "B" s[i+1] == "C" s[i+1] s i+1 i 1 "C" ans += c ans c i += 1 i 1 elif s[i] == "A":
        c += 1
     s[i] == "A" s[i] s i "A" c += 1 c 1 c = 0 c 0 i += 1 i 1 print(ans) print ans ans = 0 0 ans i = 0 0 i ans += c c ans s = list(input()) list(input()) s c = 0 0 c i += 1 1 i n = len(s) len(s) n i += 1 1 i c = 0 0 c c += 1 1 c
s = list(input())
n = len(s)
ans = 0
c = 0
i = 0
while i < n-1:
    if s[i] == "B" and s[i+1] == "C":
        ans += c
        i += 1
    elif s[i] == "A":
        c += 1
    else:
        c = 0
    i += 1
print(ans)