s=input()
s=s.replace('BC','.')
s=s.replace('B','/')
s=s.replace('C','/')
sl = s.split('/')
cnt =0
for si in sl:
    incre = 0
    for ci in si:
        if ci == 'A':
            incre +=1
        if ci == '.':
            cnt += incre
print(cnt) s=input() s input() input s=s.replace('BC','.') s s.replace('BC','.') s.replace s replace 'BC' '.' s=s.replace('B','/') s s.replace('B','/') s.replace s replace 'B' '/' s=s.replace('C','/') s s.replace('C','/') s.replace s replace 'C' '/' sl = s.split('/') sl s.split('/') s.split s split '/' cnt =0 cnt 0 for si in sl:
    incre = 0
    for ci in si:
        if ci == 'A':
            incre +=1
        if ci == '.':
            cnt += incre si sl incre = 0 incre 0 for ci in si:
        if ci == 'A':
            incre +=1
        if ci == '.':
            cnt += incre ci si if ci == 'A':
            incre +=1
         ci == 'A' ci 'A' incre +=1 incre 1 if ci == '.':
            cnt += incre ci == '.' ci '.' cnt += incre cnt incre print(cnt) print cnt cnt += incre incre cnt incre +=1 1 incre incre = 0 0 incre s=input() input() s sl = s.split('/') s.split('/') sl s=s.replace('B','/') s.replace('B','/') s cnt =0 0 cnt s=s.replace('BC','.') s.replace('BC','.') s s=s.replace('C','/') s.replace('C','/') s
s=input()
s=s.replace('BC','.')
s=s.replace('B','/')
s=s.replace('C','/')
sl = s.split('/')
cnt =0
for si in sl:
    incre = 0
    for ci in si:
        if ci == 'A':
            incre +=1
        if ci == '.':
            cnt += incre
print(cnt)
