s = input()
count = 0
s = s.replace('BC','X')
s = s.replace('B','Z').replace('C','Z')
s = s.split('Z')
for i in s:
    ac = 0
    for j in range(len(i)):
        if i[j] == 'A':
            ac += 1
        if i[j] == 'X':
            count += ac
print(count) s = input() s input() input count = 0 count 0 s = s.replace('BC','X') s s.replace('BC','X') s.replace s replace 'BC' 'X' s = s.replace('B','Z').replace('C','Z') s s.replace('B','Z').replace('C','Z') s.replace('B','Z').replace s.replace('B','Z') s.replace s replace 'B' 'Z' replace 'C' 'Z' s = s.split('Z') s s.split('Z') s.split s split 'Z' for i in s:
    ac = 0
    for j in range(len(i)):
        if i[j] == 'A':
            ac += 1
        if i[j] == 'X':
            count += ac i s ac = 0 ac 0 for j in range(len(i)):
        if i[j] == 'A':
            ac += 1
        if i[j] == 'X':
            count += ac j range(len(i)) range len(i) len i if i[j] == 'A':
            ac += 1
         i[j] == 'A' i[j] i j 'A' ac += 1 ac 1 if i[j] == 'X':
            count += ac i[j] == 'X' i[j] i j 'X' count += ac count ac print(count) print count s = input() input() s s = s.split('Z') s.split('Z') s count = 0 0 count s = s.replace('B','Z').replace('C','Z') s.replace('B','Z').replace('C','Z') s ac += 1 1 ac s = s.replace('BC','X') s.replace('BC','X') s ac = 0 0 ac count += ac ac count
s = input()
count = 0
s = s.replace('BC','X')
s = s.replace('B','Z').replace('C','Z')
s = s.split('Z')
for i in s:
    ac = 0
    for j in range(len(i)):
        if i[j] == 'A':
            ac += 1
        if i[j] == 'X':
            count += ac
print(count)