from collections import Counter

s = list(input())
chain = {}
abcs = []
kugiri = 0
countA = 0
ans = 0

for i in range(1,len(s)):
    if not((s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") or (s[i] == "A" and s[i-1] == "C") or (s[i] == "A" and s[i-1] == "A")):
        kugiri = i
        countA = 0
    elif s[i-1] == "A":
        countA += 1
    if s[i] == "C" and s[i-1] == "B":
        ans += countA

print(ans) from collections import Counter s = list(input()) s list(input()) list input() input chain = {} chain {} abcs = [] abcs [] kugiri = 0 kugiri 0 countA = 0 countA 0 ans = 0 ans 0 for i in range(1,len(s)):
    if not((s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") or (s[i] == "A" and s[i-1] == "C") or (s[i] == "A" and s[i-1] == "A")):
        kugiri = i
        countA = 0
    elif s[i-1] == "A":
        countA += 1
    if s[i] == "C" and s[i-1] == "B":
        ans += countA i range(1,len(s)) range 1 len(s) len s if not((s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") or (s[i] == "A" and s[i-1] == "C") or (s[i] == "A" and s[i-1] == "A")):
        kugiri = i
        countA = 0
    elif s[i-1] == "A":
        countA += 1
     not((s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") or (s[i] == "A" and s[i-1] == "C") or (s[i] == "A" and s[i-1] == "A")) (s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") or (s[i] == "A" and s[i-1] == "C") or (s[i] == "A" and s[i-1] == "A") (s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") or (s[i] == "A" and s[i-1] == "C") (s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") (s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") 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" s[i] == "B" and s[i-1] == "A" s[i] == "B" s[i] s i "B" s[i-1] == "A" s[i-1] s i-1 i 1 "A" s[i] == "C" and s[i-1] == "B" s[i] == "C" s[i] s i "C" s[i-1] == "B" s[i-1] s i-1 i 1 "B" s[i] == "A" and s[i-1] == "C" s[i] == "A" s[i] s i "A" s[i-1] == "C" s[i-1] s i-1 i 1 "C" s[i] == "A" and s[i-1] == "A" s[i] == "A" s[i] s i "A" s[i-1] == "A" s[i-1] s i-1 i 1 "A" kugiri = i kugiri i countA = 0 countA 0 elif s[i-1] == "A":
        countA += 1
     s[i-1] == "A" s[i-1] s i-1 i 1 "A" countA += 1 countA 1 if s[i] == "C" and s[i-1] == "B":
        ans += countA s[i] == "C" and s[i-1] == "B" s[i] == "C" s[i] s i "C" s[i-1] == "B" s[i-1] s i-1 i 1 "B" ans += countA ans countA print(ans) print ans s = list(input()) list(input()) s chain = {} {} chain abcs = [] [] abcs countA += 1 1 countA countA = 0 0 countA ans += countA countA ans kugiri = 0 0 kugiri kugiri = i i kugiri countA = 0 0 countA ans = 0 0 ans
from collections import Counter

s = list(input())
chain = {}
abcs = []
kugiri = 0
countA = 0
ans = 0

for i in range(1,len(s)):
    if not((s[i] == "B" and s[i-1] == "C") or (s[i] == "B" and s[i-1] == "A") or (s[i] == "C" and s[i-1] == "B") or (s[i] == "A" and s[i-1] == "C") or (s[i] == "A" and s[i-1] == "A")):
        kugiri = i
        countA = 0
    elif s[i-1] == "A":
        countA += 1
    if s[i] == "C" and s[i-1] == "B":
        ans += countA

print(ans)
