S = input()
S = S.replace("BC", "D")
result = 0
temp = 0
for s in S:
    if s == "A":
        temp += 1
    elif s == "D":
        result += temp
    else:
        temp = 0
print(result) S = input() S input() input S = S.replace("BC", "D") S S.replace("BC", "D") S.replace S replace "BC" "D" result = 0 result 0 temp = 0 temp 0 for s in S:
    if s == "A":
        temp += 1
    elif s == "D":
        result += temp
    else:
        temp = 0 s S if s == "A":
        temp += 1
    elif s == "D":
        result += temp
    else:
        temp = 0 s == "A" s "A" temp += 1 temp 1 elif s == "D":
        result += temp
     s == "D" s "D" result += temp result temp temp = 0 temp 0 print(result) print result S = S.replace("BC", "D") S.replace("BC", "D") S S = input() input() S result += temp temp result temp = 0 0 temp result = 0 0 result temp += 1 1 temp temp = 0 0 temp
S = input()
S = S.replace("BC", "D")
result = 0
temp = 0
for s in S:
    if s == "A":
        temp += 1
    elif s == "D":
        result += temp
    else:
        temp = 0
print(result)