sl = list(input())
dl = []

n = len(sl)
i = 0
while i < n:

    if i < n-1 and sl[i] == "B" and sl[i+1] == "C":
        dl.append("D")
        i += 2
    else:
        dl.append(sl[i])
        i += 1

ans = 0
c = 0
for d in dl:
    if d == "A":
        c += 1
    elif d == "D":
        ans += c
    else:
        c = 0


print(ans)
 sl = list(input()) sl list(input()) list input() input dl = [] dl [] n = len(sl) n len(sl) len sl i = 0 i 0 while i < n:

    if i < n-1 and sl[i] == "B" and sl[i+1] == "C":
        dl.append("D")
        i += 2
    else:
        dl.append(sl[i])
        i += 1 i < n i n if i < n-1 and sl[i] == "B" and sl[i+1] == "C":
        dl.append("D")
        i += 2
    else:
        dl.append(sl[i])
        i += 1 i < n-1 and sl[i] == "B" and sl[i+1] == "C" i < n-1 and sl[i] == "B" i < n-1 i n-1 n 1 sl[i] == "B" sl[i] sl i "B" sl[i+1] == "C" sl[i+1] sl i+1 i 1 "C" dl.append("D") dl.append dl append "D" i += 2 i 2 dl.append(sl[i]) dl.append dl append sl[i] sl i i += 1 i 1 ans = 0 ans 0 c = 0 c 0 for d in dl:
    if d == "A":
        c += 1
    elif d == "D":
        ans += c
    else:
        c = 0 d dl if d == "A":
        c += 1
    elif d == "D":
        ans += c
    else:
        c = 0 d == "A" d "A" c += 1 c 1 elif d == "D":
        ans += c
     d == "D" d "D" ans += c ans c c = 0 c 0 print(ans) print ans i += 2 2 i sl = list(input()) list(input()) sl ans = 0 0 ans c = 0 0 c c += 1 1 c dl = [] [] dl i = 0 0 i n = len(sl) len(sl) n c = 0 0 c ans += c c ans i += 1 1 i
sl = list(input())
dl = []

n = len(sl)
i = 0
while i < n:

    if i < n-1 and sl[i] == "B" and sl[i+1] == "C":
        dl.append("D")
        i += 2
    else:
        dl.append(sl[i])
        i += 1

ans = 0
c = 0
for d in dl:
    if d == "A":
        c += 1
    elif d == "D":
        ans += c
    else:
        c = 0


print(ans)

