s=input()

s=s.replace("BC","D")

count=0

c=0
while c<len(s):
    if s[c]=="A" or s[c]=="D":
        d=c
        while s[d]=="A" or s[d]=="D":
            d+=1
            if d==len(s):
                break
        an=0
        for i in range(c,d):
            if s[i]=="A":
                an+=1
            else:
                count+=an
        c=d
    else:
        c+=1

print(count) s=input() s input() input s=s.replace("BC","D") s s.replace("BC","D") s.replace s replace "BC" "D" count=0 count 0 c=0 c 0 while c<len(s):
    if s[c]=="A" or s[c]=="D":
        d=c
        while s[d]=="A" or s[d]=="D":
            d+=1
            if d==len(s):
                break
        an=0
        for i in range(c,d):
            if s[i]=="A":
                an+=1
            else:
                count+=an
        c=d
    else:
        c+=1 c<len(s) c len(s) len s if s[c]=="A" or s[c]=="D":
        d=c
        while s[d]=="A" or s[d]=="D":
            d+=1
            if d==len(s):
                break
        an=0
        for i in range(c,d):
            if s[i]=="A":
                an+=1
            else:
                count+=an
        c=d
    else:
        c+=1 s[c]=="A" or s[c]=="D" s[c]=="A" s[c] s c "A" s[c]=="D" s[c] s c "D" d=c d c while s[d]=="A" or s[d]=="D":
            d+=1
            if d==len(s):
                break
         s[d]=="A" or s[d]=="D" s[d]=="A" s[d] s d "A" s[d]=="D" s[d] s d "D" d+=1 d 1 if d==len(s):
                break
         d==len(s) d len(s) len s break an=0 an 0 for i in range(c,d):
            if s[i]=="A":
                an+=1
            else:
                count+=an
         i range(c,d) range c d if s[i]=="A":
                an+=1
            else:
                count+=an
         s[i]=="A" s[i] s i "A" an+=1 an 1 count+=an count an c=d c d c+=1 c 1 print(count) print count an+=1 1 an s=s.replace("BC","D") s.replace("BC","D") s d=c c d c+=1 1 c count+=an an count d+=1 1 d s=input() input() s an=0 0 an count=0 0 count c=d d c c=0 0 c
s=input()

s=s.replace("BC","D")

count=0

c=0
while c<len(s):
    if s[c]=="A" or s[c]=="D":
        d=c
        while s[d]=="A" or s[d]=="D":
            d+=1
            if d==len(s):
                break
        an=0
        for i in range(c,d):
            if s[i]=="A":
                an+=1
            else:
                count+=an
        c=d
    else:
        c+=1

print(count)