s=input()

while 'BC' in s:
    s=s.replace('BC','D')
ans=0
a=0
for i in range (len(s)):
    if s[i]!='A' and s[i]!='D':
        a=0
        continue
    elif s[i]=='A':
        a+=1
    elif s[i]=='D':
        ans+=a
print(ans) s=input() s input() input while 'BC' in s:
    s=s.replace('BC','D') 'BC' in s 'BC' s s=s.replace('BC','D') s s.replace('BC','D') s.replace s replace 'BC' 'D' ans=0 ans 0 a=0 a 0 for i in range (len(s)):
    if s[i]!='A' and s[i]!='D':
        a=0
        continue
    elif s[i]=='A':
        a+=1
    elif s[i]=='D':
        ans+=a i range (len(s)) range len(s) len s if s[i]!='A' and s[i]!='D':
        a=0
        continue
    elif s[i]=='A':
        a+=1
    elif s[i]=='D':
        ans+=a s[i]!='A' and s[i]!='D' s[i]!='A' s[i] s i 'A' s[i]!='D' s[i] s i 'D' a=0 a 0 continue elif s[i]=='A':
        a+=1
     s[i]=='A' s[i] s i 'A' a+=1 a 1 elif s[i]=='D':
        ans+=a s[i]=='D' s[i] s i 'D' ans+=a ans a print(ans) print ans ans=0 0 ans a=0 0 a s=input() input() s a+=1 1 a ans+=a a ans s=s.replace('BC','D') s.replace('BC','D') s a=0 0 a
s=input()

while 'BC' in s:
    s=s.replace('BC','D')
ans=0
a=0
for i in range (len(s)):
    if s[i]!='A' and s[i]!='D':
        a=0
        continue
    elif s[i]=='A':
        a+=1
    elif s[i]=='D':
        ans+=a
print(ans)