def main():
    import re
    s = input()
    s = s.replace('BC', 'D')

    obj = re.findall('[AD]+', s)
    ans = 0

    for x in obj:
        cnt = 0
        for i in x:
            if i == 'A':
                cnt += 1
            if i == 'D':
                ans += cnt

    print(ans)


if __name__ == '__main__':
    main() def main():
    import re
    s = input()
    s = s.replace('BC', 'D')

    obj = re.findall('[AD]+', s)
    ans = 0

    for x in obj:
        cnt = 0
        for i in x:
            if i == 'A':
                cnt += 1
            if i == 'D':
                ans += cnt

    print(ans) main import re re s = input() s input() input s = s.replace('BC', 'D') s s.replace('BC', 'D') s.replace s replace 'BC' 'D' obj = re.findall('[AD]+', s) obj re.findall('[AD]+', s) re.findall re findall '[AD]+' s ans = 0 ans 0 for x in obj:
        cnt = 0
        for i in x:
            if i == 'A':
                cnt += 1
            if i == 'D':
                ans += cnt

     x obj cnt = 0 cnt 0 for i in x:
            if i == 'A':
                cnt += 1
            if i == 'D':
                ans += cnt

     i x if i == 'A':
                cnt += 1
             i == 'A' i 'A' cnt += 1 cnt 1 if i == 'D':
                ans += cnt

     i == 'D' i 'D' ans += cnt ans cnt print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    import re
    s = input()
    s = s.replace('BC', 'D')

    obj = re.findall('[AD]+', s)
    ans = 0

    for x in obj:
        cnt = 0
        for i in x:
            if i == 'A':
                cnt += 1
            if i == 'D':
                ans += cnt

    print(ans) def main():
    import re
    s = input()
    s = s.replace('BC', 'D')

    obj = re.findall('[AD]+', s)
    ans = 0

    for x in obj:
        cnt = 0
        for i in x:
            if i == 'A':
                cnt += 1
            if i == 'D':
                ans += cnt

    print(ans) main
def main():
    import re
    s = input()
    s = s.replace('BC', 'D')

    obj = re.findall('[AD]+', s)
    ans = 0

    for x in obj:
        cnt = 0
        for i in x:
            if i == 'A':
                cnt += 1
            if i == 'D':
                ans += cnt

    print(ans)


if __name__ == '__main__':
    main()
