s = input()
l = len(s)
s += "D"*10
cnt = 0
ans = 0
i = 0
while i < l:
    if s[i] == "A": cnt += 1
    elif s[i:i+2] == "BC":
        ans += cnt
        i += 1
    else: cnt = 0
    i += 1
print(ans) s = input() s input() input l = len(s) l len(s) len s s += "D"*10 s "D"*10 "D" 10 cnt = 0 cnt 0 ans = 0 ans 0 i = 0 i 0 while i < l:
    if s[i] == "A": cnt += 1
    elif s[i:i+2] == "BC":
        ans += cnt
        i += 1
    else: cnt = 0
    i += 1 i < l i l if s[i] == "A": cnt += 1
    elif s[i:i+2] == "BC":
        ans += cnt
        i += 1
    else: cnt = 0
     s[i] == "A" s[i] s i "A" elif s[i:i+2] == "BC":
        ans += cnt
        i += 1
     s[i:i+2] == "BC" s[i:i+2] s i:i+2 i i+2 i 2 "BC" ans += cnt ans cnt i += 1 i 1 i += 1 i 1 print(ans) print ans ans = 0 0 ans l = len(s) len(s) l i += 1 1 i s = input() input() s cnt = 0 0 cnt s += "D"*10 "D"*10 s i = 0 0 i ans += cnt cnt ans i += 1 1 i
s = input()
l = len(s)
s += "D"*10
cnt = 0
ans = 0
i = 0
while i < l:
    if s[i] == "A": cnt += 1
    elif s[i:i+2] == "BC":
        ans += cnt
        i += 1
    else: cnt = 0
    i += 1
print(ans)