s =input()
n = len(s)
ans  = 0
cnt = 0
pre = s[0]
for i in range(n):
    if s[i] == "A":
        if pre =="B":cnt =1
        else:cnt+=1
    elif s[i] =="C":
        if pre == "B":
            ans += cnt
        else:cnt = 0
    elif s[i] == "B":
        if pre == "B":cnt = 0
    pre = s[i]
print(ans) s =input() s input() input n = len(s) n len(s) len s ans  = 0 ans 0 cnt = 0 cnt 0 pre = s[0] pre s[0] s 0 for i in range(n):
    if s[i] == "A":
        if pre =="B":cnt =1
        else:cnt+=1
    elif s[i] =="C":
        if pre == "B":
            ans += cnt
        else:cnt = 0
    elif s[i] == "B":
        if pre == "B":cnt = 0
    pre = s[i] i range(n) range n if s[i] == "A":
        if pre =="B":cnt =1
        else:cnt+=1
    elif s[i] =="C":
        if pre == "B":
            ans += cnt
        else:cnt = 0
    elif s[i] == "B":
        if pre == "B":cnt = 0
     s[i] == "A" s[i] s i "A" if pre =="B":cnt =1
        else:cnt+=1
     pre =="B" pre "B" elif s[i] =="C":
        if pre == "B":
            ans += cnt
        else:cnt = 0
     s[i] =="C" s[i] s i "C" if pre == "B":
            ans += cnt
        else:cnt = 0
     pre == "B" pre "B" ans += cnt ans cnt elif s[i] == "B":
        if pre == "B":cnt = 0
     s[i] == "B" s[i] s i "B" if pre == "B":cnt = 0
     pre == "B" pre "B" pre = s[i] pre s[i] s i print(ans) print ans ans  = 0 0 ans ans += cnt cnt ans s =input() input() s pre = s[0] s[0] pre n = len(s) len(s) n cnt = 0 0 cnt pre = s[i] s[i] pre
s =input()
n = len(s)
ans  = 0
cnt = 0
pre = s[0]
for i in range(n):
    if s[i] == "A":
        if pre =="B":cnt =1
        else:cnt+=1
    elif s[i] =="C":
        if pre == "B":
            ans += cnt
        else:cnt = 0
    elif s[i] == "B":
        if pre == "B":cnt = 0
    pre = s[i]
print(ans)
