s = list(input())
li = []
n = len(s)
ans = 0
b = False
for i in range(n-1):
    if b:
        b = False
        continue
    if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
    if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
    if s[i] == 'C':
        li.append('E')
    if s[i] == 'A':
        li.append('A')
cnt = 0
for i in range(len(li)):
    if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt
print(ans) s = list(input()) s list(input()) list input() input li = [] li [] n = len(s) n len(s) len s ans = 0 ans 0 b = False b False for i in range(n-1):
    if b:
        b = False
        continue
    if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
    if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
    if s[i] == 'C':
        li.append('E')
    if s[i] == 'A':
        li.append('A') i range(n-1) range n-1 n 1 if b:
        b = False
        continue
     b b = False b False continue if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
     s[i] + s[i+1] == 'BC' s[i] + s[i+1] s[i] s i s[i+1] s i+1 i 1 'BC' li.append('D') li.append li append 'D' b = True b True if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
     s[i] == 'B' and s[i+1] != 'C' s[i] == 'B' s[i] s i 'B' s[i+1] != 'C' s[i+1] s i+1 i 1 'C' li.append('E') li.append li append 'E' if s[i] == 'C':
        li.append('E')
     s[i] == 'C' s[i] s i 'C' li.append('E') li.append li append 'E' if s[i] == 'A':
        li.append('A') s[i] == 'A' s[i] s i 'A' li.append('A') li.append li append 'A' cnt = 0 cnt 0 for i in range(len(li)):
    if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt i range(len(li)) range len(li) len li if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt li[i] == 'A' li[i] li i 'A' cnt += 1 cnt 1 elif li[i] == 'E':
        cnt = 0
     li[i] == 'E' li[i] li i 'E' cnt = 0 cnt 0 ans += cnt ans cnt print(ans) print ans b = True True b b = False False b cnt += 1 1 cnt li = [] [] li ans += cnt cnt ans cnt = 0 0 cnt n = len(s) len(s) n s = list(input()) list(input()) s cnt = 0 0 cnt b = False False b ans = 0 0 ans
s = list(input())
li = []
n = len(s)
ans = 0
b = False
for i in range(n-1):
    if b:
        b = False
        continue
    if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
    if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
    if s[i] == 'C':
        li.append('E')
    if s[i] == 'A':
        li.append('A')
cnt = 0
for i in range(len(li)):
    if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt
print(ans)