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) 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 rep a,b='',[] a '' b [] for i in range(len(s)):
        if s[i]=='C' or s[i]=='B':
            b.append(a)
            a=''
        else:
            a+=s[i]
     i range(len(s)) range len(s) len s if s[i]=='C' or s[i]=='B':
            b.append(a)
            a=''
        else:
            a+=s[i]
     s[i]=='C' or s[i]=='B' s[i]=='C' s[i] s i 'C' s[i]=='B' s[i] s i 'B' b.append(a) b.append b append a a='' a '' a+=s[i] a s[i] s i b.append(a) b.append b append a a=[] a [] for i in range(len(b)):
        if b[i]!='':
            a.append(b[i])
     i range(len(b)) range len(b) len b if b[i]!='':
            a.append(b[i])
     b[i]!='' b[i] b i '' a.append(b[i]) a.append a append b[i] b i return a a s s s=rep(input().replace('BC','D')) s rep(input().replace('BC','D')) rep input().replace('BC','D') ().replace () input replace 'BC' 'D' b=0 b 0 for i in s:
    a=0
    for j in i:
        if j=='A':
            a+=1
        else:
            b+=a i s a=0 a 0 for j in i:
        if j=='A':
            a+=1
        else:
            b+=a j i if j=='A':
            a+=1
        else:
            b+=a j=='A' j 'A' a+=1 a 1 b+=a b a print(b) print b a+=1 1 a b+=a a b s=rep(input().replace('BC','D')) rep(input().replace('BC','D')) s b=0 0 b a=0 0 a 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 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 rep
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)