s = input()
n = len(s)
s += "???"

i = 0
ans = 0

while i < n:
    abc = []
    if s[i] == "A":
        i += 1
        abc.append(0)
        while True:
            if s[i] == "A":
                i += 1
                abc.append(0)
            elif s[i:i+2] == "BC":
                i += 2
                ans += len(abc)
            else:
                break
    i += 1

print(ans) s = input() s input() input n = len(s) n len(s) len s s += "???" s "???" i = 0 i 0 ans = 0 ans 0 while i < n:
    abc = []
    if s[i] == "A":
        i += 1
        abc.append(0)
        while True:
            if s[i] == "A":
                i += 1
                abc.append(0)
            elif s[i:i+2] == "BC":
                i += 2
                ans += len(abc)
            else:
                break
    i += 1 i < n i n abc = [] abc [] if s[i] == "A":
        i += 1
        abc.append(0)
        while True:
            if s[i] == "A":
                i += 1
                abc.append(0)
            elif s[i:i+2] == "BC":
                i += 2
                ans += len(abc)
            else:
                break
     s[i] == "A" s[i] s i "A" i += 1 i 1 abc.append(0) abc.append abc append 0 while True:
            if s[i] == "A":
                i += 1
                abc.append(0)
            elif s[i:i+2] == "BC":
                i += 2
                ans += len(abc)
            else:
                break
     True if s[i] == "A":
                i += 1
                abc.append(0)
            elif s[i:i+2] == "BC":
                i += 2
                ans += len(abc)
            else:
                break
     s[i] == "A" s[i] s i "A" i += 1 i 1 abc.append(0) abc.append abc append 0 elif s[i:i+2] == "BC":
                i += 2
                ans += len(abc)
             s[i:i+2] == "BC" s[i:i+2] s i:i+2 i i+2 i 2 "BC" i += 2 i 2 ans += len(abc) ans len(abc) len abc break i += 1 i 1 print(ans) print ans s += "???" "???" s s = input() input() s n = len(s) len(s) n ans += len(abc) len(abc) ans i += 1 1 i ans = 0 0 ans i += 1 1 i abc = [] [] abc i += 2 2 i i = 0 0 i i += 1 1 i
s = input()
n = len(s)
s += "???"

i = 0
ans = 0

while i < n:
    abc = []
    if s[i] == "A":
        i += 1
        abc.append(0)
        while True:
            if s[i] == "A":
                i += 1
                abc.append(0)
            elif s[i:i+2] == "BC":
                i += 2
                ans += len(abc)
            else:
                break
    i += 1

print(ans)