s = input()
n = len(s)

res = 0
ac = 0
i = 0
while i<n:
    if s[i]=="A":
        ac += 1
    elif s[i]=="B" and i+1<n and s[i+1]=="C":
        res += ac
        i += 1
    else:
        ac = 0
    i += 1
print(res) s = input() s input() input n = len(s) n len(s) len s res = 0 res 0 ac = 0 ac 0 i = 0 i 0 while i<n:
    if s[i]=="A":
        ac += 1
    elif s[i]=="B" and i+1<n and s[i+1]=="C":
        res += ac
        i += 1
    else:
        ac = 0
    i += 1 i<n i n if s[i]=="A":
        ac += 1
    elif s[i]=="B" and i+1<n and s[i+1]=="C":
        res += ac
        i += 1
    else:
        ac = 0
     s[i]=="A" s[i] s i "A" ac += 1 ac 1 elif s[i]=="B" and i+1<n and s[i+1]=="C":
        res += ac
        i += 1
     s[i]=="B" and i+1<n and s[i+1]=="C" s[i]=="B" and i+1<n s[i]=="B" s[i] s i "B" i+1<n i+1 i 1 n s[i+1]=="C" s[i+1] s i+1 i 1 "C" res += ac res ac i += 1 i 1 ac = 0 ac 0 i += 1 i 1 print(res) print res i += 1 1 i res += ac ac res res = 0 0 res ac += 1 1 ac s = input() input() s i = 0 0 i ac = 0 0 ac ac = 0 0 ac i += 1 1 i n = len(s) len(s) n
s = input()
n = len(s)

res = 0
ac = 0
i = 0
while i<n:
    if s[i]=="A":
        ac += 1
    elif s[i]=="B" and i+1<n and s[i+1]=="C":
        res += ac
        i += 1
    else:
        ac = 0
    i += 1
print(res)
