s = input()
ans = 0
tmp = 0
i = 0
while i < len(s)-1:
    if s[i] == "A":
        tmp += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
    else:
        tmp = 0
    i += 1
print(ans) s = input() s input() input ans = 0 ans 0 tmp = 0 tmp 0 i = 0 i 0 while i < len(s)-1:
    if s[i] == "A":
        tmp += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
    else:
        tmp = 0
    i += 1 i < len(s)-1 i len(s)-1 len(s) len s 1 if s[i] == "A":
        tmp += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
    else:
        tmp = 0
     s[i] == "A" s[i] s i "A" tmp += 1 tmp 1 elif s[i] == "B":
        if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
     s[i] == "B" s[i] s i "B" if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
     s[i+1] == "C" s[i+1] s i+1 i 1 "C" ans += tmp ans tmp i += 1 i 1 tmp = 0 tmp 0 tmp = 0 tmp 0 i += 1 i 1 print(ans) print ans i = 0 0 i ans += tmp tmp ans i += 1 1 i tmp = 0 0 tmp s = input() input() s ans = 0 0 ans i += 1 1 i tmp += 1 1 tmp tmp = 0 0 tmp tmp = 0 0 tmp
s = input()
ans = 0
tmp = 0
i = 0
while i < len(s)-1:
    if s[i] == "A":
        tmp += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
    else:
        tmp = 0
    i += 1
print(ans)