a = list(input())
ans = 0
i = 0

a_count = 0  # 連続ででたAの個数
# BC_count = 0  # BC出てきたらそれまでのAの数分

while i < len(a)-1:
    if a[i] == "A":
        count = "A"
        a_count += 1
    elif a[i]+a[i+1] == "BC":
        count = "BC"
        ans += a_count
        i += 1
    else:
        count = "VBNM"
        a_count = 0
    # print(a_count, ans, i, count)
    i += 1

print(ans) a = list(input()) a list(input()) list input() input ans = 0 ans 0 i = 0 i 0 a_count = 0 a_count 0 while i < len(a)-1:
    if a[i] == "A":
        count = "A"
        a_count += 1
    elif a[i]+a[i+1] == "BC":
        count = "BC"
        ans += a_count
        i += 1
    else:
        count = "VBNM"
        a_count = 0
    # print(a_count, ans, i, count)
    i += 1 i < len(a)-1 i len(a)-1 len(a) len a 1 if a[i] == "A":
        count = "A"
        a_count += 1
    elif a[i]+a[i+1] == "BC":
        count = "BC"
        ans += a_count
        i += 1
    else:
        count = "VBNM"
        a_count = 0
    # print(a_count, ans, i, count)
     a[i] == "A" a[i] a i "A" count = "A" count "A" a_count += 1 a_count 1 elif a[i]+a[i+1] == "BC":
        count = "BC"
        ans += a_count
        i += 1
     a[i]+a[i+1] == "BC" a[i]+a[i+1] a[i] a i a[i+1] a i+1 i 1 "BC" count = "BC" count "BC" ans += a_count ans a_count i += 1 i 1 count = "VBNM" count "VBNM" a_count = 0 a_count 0 i += 1 i 1 print(ans) print ans count = "BC" "BC" count i += 1 1 i i += 1 1 i ans += a_count a_count ans a = list(input()) list(input()) a count = "A" "A" count i = 0 0 i ans = 0 0 ans a_count = 0 0 a_count a_count = 0 0 a_count a_count += 1 1 a_count count = "VBNM" "VBNM" count
a = list(input())
ans = 0
i = 0

a_count = 0  # 連続ででたAの個数
# BC_count = 0  # BC出てきたらそれまでのAの数分

while i < len(a)-1:
    if a[i] == "A":
        count = "A"
        a_count += 1
    elif a[i]+a[i+1] == "BC":
        count = "BC"
        ans += a_count
        i += 1
    else:
        count = "VBNM"
        a_count = 0
    # print(a_count, ans, i, count)
    i += 1

print(ans)