def f():
    ans,c=0,0
    for t in input().replace('BC','y').replace('A','x'):
        if t=='y':ans+=c
        elif t=='x':c+=1
        else:c=0
    print(ans)
if __name__ == "__main__":
    f() def f():
    ans,c=0,0
    for t in input().replace('BC','y').replace('A','x'):
        if t=='y':ans+=c
        elif t=='x':c+=1
        else:c=0
    print(ans) f ans,c=0,0 ans 0 c 0 for t in input().replace('BC','y').replace('A','x'):
        if t=='y':ans+=c
        elif t=='x':c+=1
        else:c=0
     t input().replace('BC','y').replace('A','x') ().replace('BC','y').replace ().replace('BC','y') ().replace () input replace 'BC' 'y' replace 'A' 'x' if t=='y':ans+=c
        elif t=='x':c+=1
        else:c=0
     t=='y' t 'y' elif t=='x':c+=1
         t=='x' t 'x' print(ans) print ans if __name__ == "__main__":
    f() __name__ == "__main__" __name__ "__main__" f() f def f():
    ans,c=0,0
    for t in input().replace('BC','y').replace('A','x'):
        if t=='y':ans+=c
        elif t=='x':c+=1
        else:c=0
    print(ans) def f():
    ans,c=0,0
    for t in input().replace('BC','y').replace('A','x'):
        if t=='y':ans+=c
        elif t=='x':c+=1
        else:c=0
    print(ans) f
def f():
    ans,c=0,0
    for t in input().replace('BC','y').replace('A','x'):
        if t=='y':ans+=c
        elif t=='x':c+=1
        else:c=0
    print(ans)
if __name__ == "__main__":
    f()