s = input()
n = len(s)

s = s.replace("BC","X")
s += "DD"
nn = len(s)

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

s = s.replace("BC","X")
s += "DD"
nn = len(s)

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