import sys
# input = sys.stdin.readline

def main():
    s = list(input().replace("BC", "D"))
    a = 1
    for i in range(len(s)-1):
        w = "".join(s[i:i+2])
        if w == "AD":
            s[i], s[i+1] = "D", "A"
            yield a
        elif w == "AA":
            a += 1
        else:
            a = 1


print(sum(main())) import sys sys def main():
    s = list(input().replace("BC", "D"))
    a = 1
    for i in range(len(s)-1):
        w = "".join(s[i:i+2])
        if w == "AD":
            s[i], s[i+1] = "D", "A"
            yield a
        elif w == "AA":
            a += 1
        else:
            a = 1 main s = list(input().replace("BC", "D")) s list(input().replace("BC", "D")) list input().replace("BC", "D") ().replace () input replace "BC" "D" a = 1 a 1 for i in range(len(s)-1):
        w = "".join(s[i:i+2])
        if w == "AD":
            s[i], s[i+1] = "D", "A"
            yield a
        elif w == "AA":
            a += 1
        else:
            a = 1 i range(len(s)-1) range len(s)-1 len(s) len s 1 w = "".join(s[i:i+2]) w "".join(s[i:i+2]) "".join "" join s[i:i+2] s i:i+2 i i+2 i 2 if w == "AD":
            s[i], s[i+1] = "D", "A"
            yield a
        elif w == "AA":
            a += 1
        else:
            a = 1 w == "AD" w "AD" s[i], s[i+1] = "D", "A" s[i] s i "D" s[i+1] s i+1 i 1 "A" yield a a elif w == "AA":
            a += 1
         w == "AA" w "AA" a += 1 a 1 a = 1 a 1 print(sum(main())) print sum(main()) sum main() main def main():
    s = list(input().replace("BC", "D"))
    a = 1
    for i in range(len(s)-1):
        w = "".join(s[i:i+2])
        if w == "AD":
            s[i], s[i+1] = "D", "A"
            yield a
        elif w == "AA":
            a += 1
        else:
            a = 1 def main():
    s = list(input().replace("BC", "D"))
    a = 1
    for i in range(len(s)-1):
        w = "".join(s[i:i+2])
        if w == "AD":
            s[i], s[i+1] = "D", "A"
            yield a
        elif w == "AA":
            a += 1
        else:
            a = 1 main
import sys
# input = sys.stdin.readline

def main():
    s = list(input().replace("BC", "D"))
    a = 1
    for i in range(len(s)-1):
        w = "".join(s[i:i+2])
        if w == "AD":
            s[i], s[i+1] = "D", "A"
            yield a
        elif w == "AA":
            a += 1
        else:
            a = 1


print(sum(main()))
