s = input()
s = s.replace("BC", "X")
#"AX" -> "XA"

cnt = 0
ans = []
for i in range(len(s)):
    if s[i] == "A": cnt += 1
    elif s[i] == "X": ans.append(cnt)
    else: cnt = 0
print(sum(ans)) s = input() s input() input s = s.replace("BC", "X") s s.replace("BC", "X") s.replace s replace "BC" "X" cnt = 0 cnt 0 ans = [] ans [] for i in range(len(s)):
    if s[i] == "A": cnt += 1
    elif s[i] == "X": ans.append(cnt)
    else: cnt = 0 i range(len(s)) range len(s) len s if s[i] == "A": cnt += 1
    elif s[i] == "X": ans.append(cnt)
    else: cnt = 0 s[i] == "A" s[i] s i "A" elif s[i] == "X": ans.append(cnt)
     s[i] == "X" s[i] s i "X" print(sum(ans)) print sum(ans) sum ans s = input() input() s s = s.replace("BC", "X") s.replace("BC", "X") s cnt = 0 0 cnt ans = [] [] ans
s = input()
s = s.replace("BC", "X")
#"AX" -> "XA"

cnt = 0
ans = []
for i in range(len(s)):
    if s[i] == "A": cnt += 1
    elif s[i] == "X": ans.append(cnt)
    else: cnt = 0
print(sum(ans))