def main():

    s = list(input())
    ans = 0
    h = 0
    i = 0
    while i < len(s):
        if s[i] == "A":
            h += 1
            # print(i, h, s)
            if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
        else:
            h = 0
            i += 1
    return ans

if __name__ == '__main__':
    print(main()) def main():

    s = list(input())
    ans = 0
    h = 0
    i = 0
    while i < len(s):
        if s[i] == "A":
            h += 1
            # print(i, h, s)
            if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
        else:
            h = 0
            i += 1
    return ans main s = list(input()) s list(input()) list input() input ans = 0 ans 0 h = 0 h 0 i = 0 i 0 while i < len(s):
        if s[i] == "A":
            h += 1
            # print(i, h, s)
            if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
        else:
            h = 0
            i += 1
     i < len(s) i len(s) len s if s[i] == "A":
            h += 1
            # print(i, h, s)
            if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
        else:
            h = 0
            i += 1
     s[i] == "A" s[i] s i "A" h += 1 h 1 if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
         s[i:i+3] == ["A", "B", "C"] s[i:i+3] s i:i+3 i i+3 i 3 ["A", "B", "C"] "A" "B" "C" ans += h ans h h -= 1 h 1 i += 2 i 2 s[i] = "A" s[i] s i "A" i += 1 i 1 h = 0 h 0 i += 1 i 1 return ans ans if __name__ == '__main__':
    print(main()) __name__ == '__main__' __name__ '__main__' print(main()) print main() main def main():

    s = list(input())
    ans = 0
    h = 0
    i = 0
    while i < len(s):
        if s[i] == "A":
            h += 1
            # print(i, h, s)
            if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
        else:
            h = 0
            i += 1
    return ans def main():

    s = list(input())
    ans = 0
    h = 0
    i = 0
    while i < len(s):
        if s[i] == "A":
            h += 1
            # print(i, h, s)
            if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
        else:
            h = 0
            i += 1
    return ans main
def main():

    s = list(input())
    ans = 0
    h = 0
    i = 0
    while i < len(s):
        if s[i] == "A":
            h += 1
            # print(i, h, s)
            if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
        else:
            h = 0
            i += 1
    return ans

if __name__ == '__main__':
    print(main())