def main():
    S = [s for s in input()]
    As = 0
    BCs = 0
    N = len(S)
    i = 0
    ans = 0
    while i < N - 1:
        s0, s1 = S[i], S[i + 1]
        if s0 == 'A':
            As += 1
            i += 1
            continue
        if s0 != 'B' or s1 != 'C':
            As = 0
            i += 1
            continue
        BCs = 1
        i += 2
        while i < N - 1:
            s0, s1 = S[i], S[i + 1]
            if s0 != 'B' or s1 != 'C':
                break
            BCs += 1
            i += 2
        ans += As * BCs
    print(ans)

if __name__ == '__main__':
    main() def main():
    S = [s for s in input()]
    As = 0
    BCs = 0
    N = len(S)
    i = 0
    ans = 0
    while i < N - 1:
        s0, s1 = S[i], S[i + 1]
        if s0 == 'A':
            As += 1
            i += 1
            continue
        if s0 != 'B' or s1 != 'C':
            As = 0
            i += 1
            continue
        BCs = 1
        i += 2
        while i < N - 1:
            s0, s1 = S[i], S[i + 1]
            if s0 != 'B' or s1 != 'C':
                break
            BCs += 1
            i += 2
        ans += As * BCs
    print(ans) main s for s in input() for s in input() s input() input for s in input() s S = [s for s in input()] S [s for s in input()] As = 0 As 0 BCs = 0 BCs 0 N = len(S) N len(S) len S i = 0 i 0 ans = 0 ans 0 while i < N - 1:
        s0, s1 = S[i], S[i + 1]
        if s0 == 'A':
            As += 1
            i += 1
            continue
        if s0 != 'B' or s1 != 'C':
            As = 0
            i += 1
            continue
        BCs = 1
        i += 2
        while i < N - 1:
            s0, s1 = S[i], S[i + 1]
            if s0 != 'B' or s1 != 'C':
                break
            BCs += 1
            i += 2
        ans += As * BCs
     i < N - 1 i N - 1 N 1 s0, s1 = S[i], S[i + 1] s0 S[i] S i s1 S[i + 1] S i + 1 i 1 if s0 == 'A':
            As += 1
            i += 1
            continue
         s0 == 'A' s0 'A' As += 1 As 1 i += 1 i 1 continue if s0 != 'B' or s1 != 'C':
            As = 0
            i += 1
            continue
         s0 != 'B' or s1 != 'C' s0 != 'B' s0 'B' s1 != 'C' s1 'C' As = 0 As 0 i += 1 i 1 continue BCs = 1 BCs 1 i += 2 i 2 while i < N - 1:
            s0, s1 = S[i], S[i + 1]
            if s0 != 'B' or s1 != 'C':
                break
            BCs += 1
            i += 2
         i < N - 1 i N - 1 N 1 s0, s1 = S[i], S[i + 1] s0 S[i] S i s1 S[i + 1] S i + 1 i 1 if s0 != 'B' or s1 != 'C':
                break
             s0 != 'B' or s1 != 'C' s0 != 'B' s0 'B' s1 != 'C' s1 'C' break BCs += 1 BCs 1 i += 2 i 2 ans += As * BCs ans As * BCs As BCs print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    S = [s for s in input()]
    As = 0
    BCs = 0
    N = len(S)
    i = 0
    ans = 0
    while i < N - 1:
        s0, s1 = S[i], S[i + 1]
        if s0 == 'A':
            As += 1
            i += 1
            continue
        if s0 != 'B' or s1 != 'C':
            As = 0
            i += 1
            continue
        BCs = 1
        i += 2
        while i < N - 1:
            s0, s1 = S[i], S[i + 1]
            if s0 != 'B' or s1 != 'C':
                break
            BCs += 1
            i += 2
        ans += As * BCs
    print(ans) def main():
    S = [s for s in input()]
    As = 0
    BCs = 0
    N = len(S)
    i = 0
    ans = 0
    while i < N - 1:
        s0, s1 = S[i], S[i + 1]
        if s0 == 'A':
            As += 1
            i += 1
            continue
        if s0 != 'B' or s1 != 'C':
            As = 0
            i += 1
            continue
        BCs = 1
        i += 2
        while i < N - 1:
            s0, s1 = S[i], S[i + 1]
            if s0 != 'B' or s1 != 'C':
                break
            BCs += 1
            i += 2
        ans += As * BCs
    print(ans) main
def main():
    S = [s for s in input()]
    As = 0
    BCs = 0
    N = len(S)
    i = 0
    ans = 0
    while i < N - 1:
        s0, s1 = S[i], S[i + 1]
        if s0 == 'A':
            As += 1
            i += 1
            continue
        if s0 != 'B' or s1 != 'C':
            As = 0
            i += 1
            continue
        BCs = 1
        i += 2
        while i < N - 1:
            s0, s1 = S[i], S[i + 1]
            if s0 != 'B' or s1 != 'C':
                break
            BCs += 1
            i += 2
        ans += As * BCs
    print(ans)

if __name__ == '__main__':
    main()
