#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()
    S = S.replace('BC','Z')
    S = S.replace('B',' ')
    S = S.replace('C',' ')
    S = S[::-1]
    S = S.split()
    ret = 0
    for s in S:
        zcn = 0
        for si in s:
            zcn += (si == 'Z')
            ret += zcn * (si == 'A')
    print(ret)

if __name__ == '__main__':
    main() def main():
    S = input()
    S = S.replace('BC','Z')
    S = S.replace('B',' ')
    S = S.replace('C',' ')
    S = S[::-1]
    S = S.split()
    ret = 0
    for s in S:
        zcn = 0
        for si in s:
            zcn += (si == 'Z')
            ret += zcn * (si == 'A')
    print(ret) main S = input() S input() input S = S.replace('BC','Z') S S.replace('BC','Z') S.replace S replace 'BC' 'Z' S = S.replace('B',' ') S S.replace('B',' ') S.replace S replace 'B' ' ' S = S.replace('C',' ') S S.replace('C',' ') S.replace S replace 'C' ' ' S = S[::-1] S S[::-1] S ::-1 -1 S = S.split() S S.split() S.split S split ret = 0 ret 0 for s in S:
        zcn = 0
        for si in s:
            zcn += (si == 'Z')
            ret += zcn * (si == 'A')
     s S zcn = 0 zcn 0 for si in s:
            zcn += (si == 'Z')
            ret += zcn * (si == 'A')
     si s zcn += (si == 'Z') zcn si == 'Z' si 'Z' ret += zcn * (si == 'A') ret zcn * (si == 'A') zcn si == 'A' si 'A' print(ret) print ret if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    S = input()
    S = S.replace('BC','Z')
    S = S.replace('B',' ')
    S = S.replace('C',' ')
    S = S[::-1]
    S = S.split()
    ret = 0
    for s in S:
        zcn = 0
        for si in s:
            zcn += (si == 'Z')
            ret += zcn * (si == 'A')
    print(ret) def main():
    S = input()
    S = S.replace('BC','Z')
    S = S.replace('B',' ')
    S = S.replace('C',' ')
    S = S[::-1]
    S = S.split()
    ret = 0
    for s in S:
        zcn = 0
        for si in s:
            zcn += (si == 'Z')
            ret += zcn * (si == 'A')
    print(ret) main
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    S = input()
    S = S.replace('BC','Z')
    S = S.replace('B',' ')
    S = S.replace('C',' ')
    S = S[::-1]
    S = S.split()
    ret = 0
    for s in S:
        zcn = 0
        for si in s:
            zcn += (si == 'Z')
            ret += zcn * (si == 'A')
    print(ret)

if __name__ == '__main__':
    main()