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