def main():
    S = list(input())
    N = len(S)
    if N <= 2:
        print(0)
        exit()
    T = []
    flag = False
    for i in range(N-1):
        if flag:
            flag = False
            continue

        if S[i] == 'B' and S[i+1] == 'C':
            T.append('D')
            flag = True
        else:
            T.append(S[i])
        
    if not (S[i-2] == 'B' and S[i-1] == 'C'):
        T.append(S[i-1])
    
    M = len(T)
    d = [0] * T.count('D')
    ans = 0
    a = 0
    for i in range(M):
        if T[i] == 'A':
            a += 1
        elif T[i] == 'D':
            ans += a
        else:
            a = 0
    print(ans)

if __name__ == "__main__":
    main() def main():
    S = list(input())
    N = len(S)
    if N <= 2:
        print(0)
        exit()
    T = []
    flag = False
    for i in range(N-1):
        if flag:
            flag = False
            continue

        if S[i] == 'B' and S[i+1] == 'C':
            T.append('D')
            flag = True
        else:
            T.append(S[i])
        
    if not (S[i-2] == 'B' and S[i-1] == 'C'):
        T.append(S[i-1])
    
    M = len(T)
    d = [0] * T.count('D')
    ans = 0
    a = 0
    for i in range(M):
        if T[i] == 'A':
            a += 1
        elif T[i] == 'D':
            ans += a
        else:
            a = 0
    print(ans) main S = list(input()) S list(input()) list input() input N = len(S) N len(S) len S if N <= 2:
        print(0)
        exit()
     N <= 2 N 2 print(0) print 0 exit() exit T = [] T [] flag = False flag False for i in range(N-1):
        if flag:
            flag = False
            continue

        if S[i] == 'B' and S[i+1] == 'C':
            T.append('D')
            flag = True
        else:
            T.append(S[i])
        
     i range(N-1) range N-1 N 1 if flag:
            flag = False
            continue

         flag flag = False flag False continue if S[i] == 'B' and S[i+1] == 'C':
            T.append('D')
            flag = True
        else:
            T.append(S[i])
        
     S[i] == 'B' and S[i+1] == 'C' S[i] == 'B' S[i] S i 'B' S[i+1] == 'C' S[i+1] S i+1 i 1 'C' T.append('D') T.append T append 'D' flag = True flag True T.append(S[i]) T.append T append S[i] S i if not (S[i-2] == 'B' and S[i-1] == 'C'):
        T.append(S[i-1])
    
     not (S[i-2] == 'B' and S[i-1] == 'C') S[i-2] == 'B' and S[i-1] == 'C' S[i-2] == 'B' S[i-2] S i-2 i 2 'B' S[i-1] == 'C' S[i-1] S i-1 i 1 'C' T.append(S[i-1]) T.append T append S[i-1] S i-1 i 1 M = len(T) M len(T) len T d = [0] * T.count('D') d [0] * T.count('D') [0] 0 T.count('D') T.count T count 'D' ans = 0 ans 0 a = 0 a 0 for i in range(M):
        if T[i] == 'A':
            a += 1
        elif T[i] == 'D':
            ans += a
        else:
            a = 0
     i range(M) range M if T[i] == 'A':
            a += 1
        elif T[i] == 'D':
            ans += a
        else:
            a = 0
     T[i] == 'A' T[i] T i 'A' a += 1 a 1 elif T[i] == 'D':
            ans += a
         T[i] == 'D' T[i] T i 'D' ans += a ans a a = 0 a 0 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    S = list(input())
    N = len(S)
    if N <= 2:
        print(0)
        exit()
    T = []
    flag = False
    for i in range(N-1):
        if flag:
            flag = False
            continue

        if S[i] == 'B' and S[i+1] == 'C':
            T.append('D')
            flag = True
        else:
            T.append(S[i])
        
    if not (S[i-2] == 'B' and S[i-1] == 'C'):
        T.append(S[i-1])
    
    M = len(T)
    d = [0] * T.count('D')
    ans = 0
    a = 0
    for i in range(M):
        if T[i] == 'A':
            a += 1
        elif T[i] == 'D':
            ans += a
        else:
            a = 0
    print(ans) def main():
    S = list(input())
    N = len(S)
    if N <= 2:
        print(0)
        exit()
    T = []
    flag = False
    for i in range(N-1):
        if flag:
            flag = False
            continue

        if S[i] == 'B' and S[i+1] == 'C':
            T.append('D')
            flag = True
        else:
            T.append(S[i])
        
    if not (S[i-2] == 'B' and S[i-1] == 'C'):
        T.append(S[i-1])
    
    M = len(T)
    d = [0] * T.count('D')
    ans = 0
    a = 0
    for i in range(M):
        if T[i] == 'A':
            a += 1
        elif T[i] == 'D':
            ans += a
        else:
            a = 0
    print(ans) main
def main():
    S = list(input())
    N = len(S)
    if N <= 2:
        print(0)
        exit()
    T = []
    flag = False
    for i in range(N-1):
        if flag:
            flag = False
            continue

        if S[i] == 'B' and S[i+1] == 'C':
            T.append('D')
            flag = True
        else:
            T.append(S[i])
        
    if not (S[i-2] == 'B' and S[i-1] == 'C'):
        T.append(S[i-1])
    
    M = len(T)
    d = [0] * T.count('D')
    ans = 0
    a = 0
    for i in range(M):
        if T[i] == 'A':
            a += 1
        elif T[i] == 'D':
            ans += a
        else:
            a = 0
    print(ans)

if __name__ == "__main__":
    main()