s = input()
s_= s.replace("A", "0").replace("BC", "1").replace("B", "2").replace("C", "2")
s_012 = list(map(int, list(s_)))
count = 0
i = 0
ans = 0
while i < len(s_012):
    if s_012[i] == 0:
        count += 1
    elif s_012[i] == 1:
        ans += count
    else:
        count = 0
    i += 1

print(ans) s = input() s input() input s_= s.replace("A", "0").replace("BC", "1").replace("B", "2").replace("C", "2") s_ s.replace("A", "0").replace("BC", "1").replace("B", "2").replace("C", "2") s.replace("A", "0").replace("BC", "1").replace("B", "2").replace s.replace("A", "0").replace("BC", "1").replace("B", "2") s.replace("A", "0").replace("BC", "1").replace s.replace("A", "0").replace("BC", "1") s.replace("A", "0").replace s.replace("A", "0") s.replace s replace "A" "0" replace "BC" "1" replace "B" "2" replace "C" "2" s_012 = list(map(int, list(s_))) s_012 list(map(int, list(s_))) list map(int, list(s_)) map int list(s_) list s_ count = 0 count 0 i = 0 i 0 ans = 0 ans 0 while i < len(s_012):
    if s_012[i] == 0:
        count += 1
    elif s_012[i] == 1:
        ans += count
    else:
        count = 0
    i += 1 i < len(s_012) i len(s_012) len s_012 if s_012[i] == 0:
        count += 1
    elif s_012[i] == 1:
        ans += count
    else:
        count = 0
     s_012[i] == 0 s_012[i] s_012 i 0 count += 1 count 1 elif s_012[i] == 1:
        ans += count
     s_012[i] == 1 s_012[i] s_012 i 1 ans += count ans count count = 0 count 0 i += 1 i 1 print(ans) print ans count += 1 1 count s_012 = list(map(int, list(s_))) list(map(int, list(s_))) s_012 s_= s.replace("A", "0").replace("BC", "1").replace("B", "2").replace("C", "2") s.replace("A", "0").replace("BC", "1").replace("B", "2").replace("C", "2") s_ ans = 0 0 ans s = input() input() s count = 0 0 count i += 1 1 i ans += count count ans count = 0 0 count i = 0 0 i
s = input()
s_= s.replace("A", "0").replace("BC", "1").replace("B", "2").replace("C", "2")
s_012 = list(map(int, list(s_)))
count = 0
i = 0
ans = 0
while i < len(s_012):
    if s_012[i] == 0:
        count += 1
    elif s_012[i] == 1:
        ans += count
    else:
        count = 0
    i += 1

print(ans)