def rep(s):

    a,b='',[]

    for i in range(len(s)):

        if s[i]=='C' or s[i]=='B':

            b.append(a)

            a=''

        else:

            a+=s[i]

    b.append(a)

    a=[]

    for i in range(len(b)):

        if b[i]!='':

            a.append(b[i])

    return a

s=rep(input().replace('BC','D'))

b=0

for i in s:

    a=0

    for j in i:

        if j=='A':

            a+=1

        else:

            b+=a

print(b)
s=input().replace('BC','D')

a=[]

b=''

for c in s:

    if c=='B' or c=='C':

        a.append(b)

        b=''

    else:

        b+=c

a.append(b)

ans=0

for i in a:

    ac=0

    for j in i:

        if j=='A':

            ac+=1

        else:

            ans+=ac

print(ans)
def rep(s):
    a, b = "", []
    for i in range(len(s)):
        if s[i] == "C" or s[i] == "B":
            b.append(a)
            a = ""
        else:
            a += s[i]
    b.append(a)
    a = []
    for i in range(len(b)):
        if b[i] != "":
            a.append(b[i])
    return a


s = rep(input().replace("BC", "D"))
b = 0
for i in s:
    a = 0
    for j in i:
        if j == "A":
            a += 1
        else:
            b += a
print(b)

s = input().replace("BC", "D")
a = []
b = ""
for c in s:
    if c == "B" or c == "C":
        a.append(b)
        b = ""
    else:
        b += c
a.append(b)
ans = 0
for i in a:
    ac = 0
    for j in i:
        if j == "A":
            ac += 1
        else:
            ans += ac
print(ans)

-def rep(s): -    a, b = "", [] -    for i in range(len(s)): -        if s[i] == "C" or s[i] == "B": -            b.append(a) -            a = "" -        else: -            a += s[i] -    b.append(a) -    a = [] -    for i in range(len(b)): -        if b[i] != "": -            a.append(b[i]) -    return a - - -s = rep(input().replace("BC", "D")) -b = 0 -for i in s: -    a = 0 +s = input().replace("BC", "D") +a = [] +b = "" +for c in s: +    if c == "B" or c == "C": +        a.append(b) +        b = "" +    else: +        b += c +a.append(b) +ans = 0 +for i in a: +    ac = 0 -            a += 1 +            ac += 1 -            b += a -print(b) +            ans += ac +print(ans)