s = str(input())
lis = []
cnt = 0

while cnt < len(s):
    if cnt+1 < len(s) and (s[cnt] == "B" and s[cnt+1] == "C"):
        lis.append("D")
        cnt += 1
    else:
        lis.append(s[cnt])
    cnt += 1
  #    print(lis)

ans = 0
num = 0
for i in range(len(lis)):
    if lis[i] == "A":
        num += 1
    elif lis[i] == "D":
        ans += num
    else:
        num = 0
print(ans) s = str(input()) s str(input()) str input() input lis = [] lis [] cnt = 0 cnt 0 while cnt < len(s):
    if cnt+1 < len(s) and (s[cnt] == "B" and s[cnt+1] == "C"):
        lis.append("D")
        cnt += 1
    else:
        lis.append(s[cnt])
    cnt += 1
  #    print(lis) cnt < len(s) cnt len(s) len s if cnt+1 < len(s) and (s[cnt] == "B" and s[cnt+1] == "C"):
        lis.append("D")
        cnt += 1
    else:
        lis.append(s[cnt])
     cnt+1 < len(s) and (s[cnt] == "B" and s[cnt+1] == "C") cnt+1 < len(s) cnt+1 cnt 1 len(s) len s s[cnt] == "B" and s[cnt+1] == "C" s[cnt] == "B" s[cnt] s cnt "B" s[cnt+1] == "C" s[cnt+1] s cnt+1 cnt 1 "C" lis.append("D") lis.append lis append "D" cnt += 1 cnt 1 lis.append(s[cnt]) lis.append lis append s[cnt] s cnt cnt += 1 cnt 1 ans = 0 ans 0 num = 0 num 0 for i in range(len(lis)):
    if lis[i] == "A":
        num += 1
    elif lis[i] == "D":
        ans += num
    else:
        num = 0 i range(len(lis)) range len(lis) len lis if lis[i] == "A":
        num += 1
    elif lis[i] == "D":
        ans += num
    else:
        num = 0 lis[i] == "A" lis[i] lis i "A" num += 1 num 1 elif lis[i] == "D":
        ans += num
     lis[i] == "D" lis[i] lis i "D" ans += num ans num num = 0 num 0 print(ans) print ans s = str(input()) str(input()) s num = 0 0 num ans = 0 0 ans cnt = 0 0 cnt cnt += 1 1 cnt num = 0 0 num lis = [] [] lis num += 1 1 num ans += num num ans cnt += 1 1 cnt
s = str(input())
lis = []
cnt = 0

while cnt < len(s):
    if cnt+1 < len(s) and (s[cnt] == "B" and s[cnt+1] == "C"):
        lis.append("D")
        cnt += 1
    else:
        lis.append(s[cnt])
    cnt += 1
  #    print(lis)

ans = 0
num = 0
for i in range(len(lis)):
    if lis[i] == "A":
        num += 1
    elif lis[i] == "D":
        ans += num
    else:
        num = 0
print(ans)