S = input().replace("BC", "1")

ans = 0

a = 0

for s in S:

    if s == "A":

        a += 1

    elif s == "1":

        ans += a

    else:

        a = 0

print(ans)



def main():

  S = input().replace("BC", "1")

  ans = 0

  a = 0

  for s in S:

      if s == "A":

          a += 1

      elif s == "1":

          ans += a

      else:

          a = 0

  print(ans)



main()
S = input().replace("BC", "1")
ans = 0
a = 0
for s in S:
    if s == "A":
        a += 1
    elif s == "1":
        ans += a
    else:
        a = 0
print(ans)

def main():
    S = input().replace("BC", "1")
    ans = 0
    a = 0
    for s in S:
        if s == "A":
            a += 1
        elif s == "1":
            ans += a
        else:
            a = 0
    print(ans)


main()

-S = input().replace("BC", "1") -ans = 0 -a = 0 -for s in S: -    if s == "A": -        a += 1 -    elif s == "1": -        ans += a -    else: -        a = 0 -print(ans) +def main(): +    S = input().replace("BC", "1") +    ans = 0 +    a = 0 +    for s in S: +        if s == "A": +            a += 1 +        elif s == "1": +            ans += a +        else: +            a = 0 +    print(ans) + + +main()