s = input()
l = len(s)
s += "0"
ans = 0
a_cnt = 0
skip = False
for i in range(l):
    if skip:
        skip = False
        continue
    if s[i] == "A":
        a_cnt += 1
    elif s[i] == "B" and s[i+1] == "C":
        ans += a_cnt
        skip = True
    else:
        a_cnt = 0

print(ans) s = input() s input() input l = len(s) l len(s) len s s += "0" s "0" ans = 0 ans 0 a_cnt = 0 a_cnt 0 skip = False skip False for i in range(l):
    if skip:
        skip = False
        continue
    if s[i] == "A":
        a_cnt += 1
    elif s[i] == "B" and s[i+1] == "C":
        ans += a_cnt
        skip = True
    else:
        a_cnt = 0 i range(l) range l if skip:
        skip = False
        continue
     skip skip = False skip False continue if s[i] == "A":
        a_cnt += 1
    elif s[i] == "B" and s[i+1] == "C":
        ans += a_cnt
        skip = True
    else:
        a_cnt = 0 s[i] == "A" s[i] s i "A" a_cnt += 1 a_cnt 1 elif s[i] == "B" and s[i+1] == "C":
        ans += a_cnt
        skip = True
     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" ans += a_cnt ans a_cnt skip = True skip True a_cnt = 0 a_cnt 0 print(ans) print ans skip = False False skip a_cnt = 0 0 a_cnt skip = True True skip a_cnt += 1 1 a_cnt s = input() input() s s += "0" "0" s skip = False False skip a_cnt = 0 0 a_cnt l = len(s) len(s) l ans = 0 0 ans ans += a_cnt a_cnt ans
s = input()
l = len(s)
s += "0"
ans = 0
a_cnt = 0
skip = False
for i in range(l):
    if skip:
        skip = False
        continue
    if s[i] == "A":
        a_cnt += 1
    elif s[i] == "B" and s[i+1] == "C":
        ans += a_cnt
        skip = True
    else:
        a_cnt = 0

print(ans)
