def main():
    s = input()
    s = s.replace("BC", "D")
    #print(s)
    cnt_a = 0
    ans = 0
    for st in s:
        if st == "A":
            cnt_a += 1
        elif st == "D":
            ans += cnt_a
        else:
            cnt_a = 0
    print(ans)


if __name__ == "__main__":
    main() def main():
    s = input()
    s = s.replace("BC", "D")
    #print(s)
    cnt_a = 0
    ans = 0
    for st in s:
        if st == "A":
            cnt_a += 1
        elif st == "D":
            ans += cnt_a
        else:
            cnt_a = 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" cnt_a = 0 cnt_a 0 ans = 0 ans 0 for st in s:
        if st == "A":
            cnt_a += 1
        elif st == "D":
            ans += cnt_a
        else:
            cnt_a = 0
     st s if st == "A":
            cnt_a += 1
        elif st == "D":
            ans += cnt_a
        else:
            cnt_a = 0
     st == "A" st "A" cnt_a += 1 cnt_a 1 elif st == "D":
            ans += cnt_a
         st == "D" st "D" ans += cnt_a ans cnt_a cnt_a = 0 cnt_a 0 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    s = input()
    s = s.replace("BC", "D")
    #print(s)
    cnt_a = 0
    ans = 0
    for st in s:
        if st == "A":
            cnt_a += 1
        elif st == "D":
            ans += cnt_a
        else:
            cnt_a = 0
    print(ans) def main():
    s = input()
    s = s.replace("BC", "D")
    #print(s)
    cnt_a = 0
    ans = 0
    for st in s:
        if st == "A":
            cnt_a += 1
        elif st == "D":
            ans += cnt_a
        else:
            cnt_a = 0
    print(ans) main
def main():
    s = input()
    s = s.replace("BC", "D")
    #print(s)
    cnt_a = 0
    ans = 0
    for st in s:
        if st == "A":
            cnt_a += 1
        elif st == "D":
            ans += cnt_a
        else:
            cnt_a = 0
    print(ans)


if __name__ == "__main__":
    main()
