def main():
    word = input().replace("BC", "X") + " "
    answer = 0
    count_a = 0
    for i in range(len(word)):
        if word[i] == "A":
            count_a += 1
        elif word[i] == "X":
            answer += count_a
        else:
            count_a = 0
    print(answer)


if __name__ == '__main__':
    main()
 def main():
    word = input().replace("BC", "X") + " "
    answer = 0
    count_a = 0
    for i in range(len(word)):
        if word[i] == "A":
            count_a += 1
        elif word[i] == "X":
            answer += count_a
        else:
            count_a = 0
    print(answer) main word = input().replace("BC", "X") + " " word input().replace("BC", "X") + " " input().replace("BC", "X") ().replace () input replace "BC" "X" " " answer = 0 answer 0 count_a = 0 count_a 0 for i in range(len(word)):
        if word[i] == "A":
            count_a += 1
        elif word[i] == "X":
            answer += count_a
        else:
            count_a = 0
     i range(len(word)) range len(word) len word if word[i] == "A":
            count_a += 1
        elif word[i] == "X":
            answer += count_a
        else:
            count_a = 0
     word[i] == "A" word[i] word i "A" count_a += 1 count_a 1 elif word[i] == "X":
            answer += count_a
         word[i] == "X" word[i] word i "X" answer += count_a answer count_a count_a = 0 count_a 0 print(answer) print answer if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    word = input().replace("BC", "X") + " "
    answer = 0
    count_a = 0
    for i in range(len(word)):
        if word[i] == "A":
            count_a += 1
        elif word[i] == "X":
            answer += count_a
        else:
            count_a = 0
    print(answer) def main():
    word = input().replace("BC", "X") + " "
    answer = 0
    count_a = 0
    for i in range(len(word)):
        if word[i] == "A":
            count_a += 1
        elif word[i] == "X":
            answer += count_a
        else:
            count_a = 0
    print(answer) main
def main():
    word = input().replace("BC", "X") + " "
    answer = 0
    count_a = 0
    for i in range(len(word)):
        if word[i] == "A":
            count_a += 1
        elif word[i] == "X":
            answer += count_a
        else:
            count_a = 0
    print(answer)


if __name__ == '__main__':
    main()

