def main():
    s = list(input().rstrip())
    ans = 0
    cnt = 0
    for i in range(len(s)-2):
        if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
    print(ans)

if __name__ == "__main__":
    main() def main():
    s = list(input().rstrip())
    ans = 0
    cnt = 0
    for i in range(len(s)-2):
        if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
    print(ans) main s = list(input().rstrip()) s list(input().rstrip()) list input().rstrip() ().rstrip () input rstrip ans = 0 ans 0 cnt = 0 cnt 0 for i in range(len(s)-2):
        if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
     i range(len(s)-2) range len(s)-2 len(s) len s 2 if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
         s[i] == "A" s[i] s i "A" cnt += 1 cnt 1 cnt = 0 cnt 0 if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
     s[i] == "A" and s[i+1] == "B" and s[i+2] == "C" s[i] == "A" and s[i+1] == "B" s[i] == "A" s[i] s i "A" s[i+1] == "B" s[i+1] s i+1 i 1 "B" s[i+2] == "C" s[i+2] s i+2 i 2 "C" ans += cnt ans cnt if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
     cnt == 1 cnt 1 s[i+2] = "A" s[i+2] s i+2 i 2 "A" cnt = 0 cnt 0 s[i+1] = "A" s[i+1] s i+1 i 1 "A" s[i+2] = "A" s[i+2] s i+2 i 2 "A" cnt -= 2 cnt 2 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    s = list(input().rstrip())
    ans = 0
    cnt = 0
    for i in range(len(s)-2):
        if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
    print(ans) def main():
    s = list(input().rstrip())
    ans = 0
    cnt = 0
    for i in range(len(s)-2):
        if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
    print(ans) main
def main():
    s = list(input().rstrip())
    ans = 0
    cnt = 0
    for i in range(len(s)-2):
        if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
    print(ans)

if __name__ == "__main__":
    main()