#coding: utf-8
#!/home/nicetacks/.pyenv/shims/python3

s = input()

while "BC" in s:
    s = s.replace("BC", "D")

ret  = 0
numA = 0
for i in range(len(s)):
    if s[i] == "A":
        numA += 1
    elif s[i] == "D":
        ret += numA
    else:
        numA = 0

print(ret)
 s = input() s input() input while "BC" in s:
    s = s.replace("BC", "D") "BC" in s "BC" s s = s.replace("BC", "D") s s.replace("BC", "D") s.replace s replace "BC" "D" ret  = 0 ret 0 numA = 0 numA 0 for i in range(len(s)):
    if s[i] == "A":
        numA += 1
    elif s[i] == "D":
        ret += numA
    else:
        numA = 0 i range(len(s)) range len(s) len s if s[i] == "A":
        numA += 1
    elif s[i] == "D":
        ret += numA
    else:
        numA = 0 s[i] == "A" s[i] s i "A" numA += 1 numA 1 elif s[i] == "D":
        ret += numA
     s[i] == "D" s[i] s i "D" ret += numA ret numA numA = 0 numA 0 print(ret) print ret numA = 0 0 numA numA += 1 1 numA s = input() input() s ret += numA numA ret s = s.replace("BC", "D") s.replace("BC", "D") s numA = 0 0 numA ret  = 0 0 ret
#coding: utf-8
#!/home/nicetacks/.pyenv/shims/python3

s = input()

while "BC" in s:
    s = s.replace("BC", "D")

ret  = 0
numA = 0
for i in range(len(s)):
    if s[i] == "A":
        numA += 1
    elif s[i] == "D":
        ret += numA
    else:
        numA = 0

print(ret)

