s = list(input())[::-1]+["L"]
n = len(s)

ans = 0
count = 0
now = 0
while now < n-1:
    if s[now] == "C" and s[now+1] == "B":
        count += 1
        now += 2
    elif s[now] == "A":
        if count > 0:
            ans += count
        else:
            count = 0
        now += 1
    else:
        count = 0
        now += 1
print(ans) s = list(input())[::-1]+["L"] s list(input())[::-1]+["L"] list(input())[::-1] (input()) list input() input ::-1 -1 ["L"] "L" n = len(s) n len(s) len s ans = 0 ans 0 count = 0 count 0 now = 0 now 0 while now < n-1:
    if s[now] == "C" and s[now+1] == "B":
        count += 1
        now += 2
    elif s[now] == "A":
        if count > 0:
            ans += count
        else:
            count = 0
        now += 1
    else:
        count = 0
        now += 1 now < n-1 now n-1 n 1 if s[now] == "C" and s[now+1] == "B":
        count += 1
        now += 2
    elif s[now] == "A":
        if count > 0:
            ans += count
        else:
            count = 0
        now += 1
    else:
        count = 0
        now += 1 s[now] == "C" and s[now+1] == "B" s[now] == "C" s[now] s now "C" s[now+1] == "B" s[now+1] s now+1 now 1 "B" count += 1 count 1 now += 2 now 2 elif s[now] == "A":
        if count > 0:
            ans += count
        else:
            count = 0
        now += 1
     s[now] == "A" s[now] s now "A" if count > 0:
            ans += count
        else:
            count = 0
         count > 0 count 0 ans += count ans count count = 0 count 0 now += 1 now 1 count = 0 count 0 now += 1 now 1 print(ans) print ans now += 1 1 now n = len(s) len(s) n ans = 0 0 ans now = 0 0 now now += 1 1 now count = 0 0 count ans += count count ans count = 0 0 count now += 2 2 now count = 0 0 count count += 1 1 count s = list(input())[::-1]+["L"] list(input())[::-1]+["L"] s
s = list(input())[::-1]+["L"]
n = len(s)

ans = 0
count = 0
now = 0
while now < n-1:
    if s[now] == "C" and s[now+1] == "B":
        count += 1
        now += 2
    elif s[now] == "A":
        if count > 0:
            ans += count
        else:
            count = 0
        now += 1
    else:
        count = 0
        now += 1
print(ans)