s = input()
n = len(s)
p = []
flag = False
for i in range(n-1):
    if flag:
        flag = False
        continue 
    if s[i] == "B" and s[i+1] == "C":
        flag = True
        p.append("#")
    elif s[i] == "A":
        p.append(s[i])
    else:
        p.append("!")

nowa = 0
ans = 0
for i in range(len(p)):
    if p[i] == "A":
        nowa += 1
    elif p[i] == "#":
        ans += nowa
    elif p[i] == "!":
        nowa = 0
print(ans) s = input() s input() input n = len(s) n len(s) len s p = [] p [] flag = False flag False for i in range(n-1):
    if flag:
        flag = False
        continue 
    if s[i] == "B" and s[i+1] == "C":
        flag = True
        p.append("#")
    elif s[i] == "A":
        p.append(s[i])
    else:
        p.append("!") 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":
        flag = True
        p.append("#")
    elif s[i] == "A":
        p.append(s[i])
    else:
        p.append("!") 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" flag = True flag True p.append("#") p.append p append "#" elif s[i] == "A":
        p.append(s[i])
     s[i] == "A" s[i] s i "A" p.append(s[i]) p.append p append s[i] s i p.append("!") p.append p append "!" nowa = 0 nowa 0 ans = 0 ans 0 for i in range(len(p)):
    if p[i] == "A":
        nowa += 1
    elif p[i] == "#":
        ans += nowa
    elif p[i] == "!":
        nowa = 0 i range(len(p)) range len(p) len p if p[i] == "A":
        nowa += 1
    elif p[i] == "#":
        ans += nowa
    elif p[i] == "!":
        nowa = 0 p[i] == "A" p[i] p i "A" nowa += 1 nowa 1 elif p[i] == "#":
        ans += nowa
     p[i] == "#" p[i] p i "#" ans += nowa ans nowa elif p[i] == "!":
        nowa = 0 p[i] == "!" p[i] p i "!" nowa = 0 nowa 0 print(ans) print ans n = len(s) len(s) n ans = 0 0 ans p = [] [] p s = input() input() s nowa = 0 0 nowa ans += nowa nowa ans flag = False False flag nowa += 1 1 nowa flag = True True flag nowa = 0 0 nowa flag = False False flag
s = input()
n = len(s)
p = []
flag = False
for i in range(n-1):
    if flag:
        flag = False
        continue 
    if s[i] == "B" and s[i+1] == "C":
        flag = True
        p.append("#")
    elif s[i] == "A":
        p.append(s[i])
    else:
        p.append("!")

nowa = 0
ans = 0
for i in range(len(p)):
    if p[i] == "A":
        nowa += 1
    elif p[i] == "#":
        ans += nowa
    elif p[i] == "!":
        nowa = 0
print(ans)