s = input()
s = s.replace('BC','D')
a_cnt = 0
before_s = 'A'
ans = 0
for i in range(len(s)):

    if s[i] == 'A':
        a_cnt += 1
        before_s = s[i]
    elif (s[i]=='D'):
        ans +=a_cnt
        before_s = 'A'
    else:
        a_cnt = 0
        before_s = s[i]

print(ans) s = input() s input() input s = s.replace('BC','D') s s.replace('BC','D') s.replace s replace 'BC' 'D' a_cnt = 0 a_cnt 0 before_s = 'A' before_s 'A' ans = 0 ans 0 for i in range(len(s)):

    if s[i] == 'A':
        a_cnt += 1
        before_s = s[i]
    elif (s[i]=='D'):
        ans +=a_cnt
        before_s = 'A'
    else:
        a_cnt = 0
        before_s = s[i] i range(len(s)) range len(s) len s if s[i] == 'A':
        a_cnt += 1
        before_s = s[i]
    elif (s[i]=='D'):
        ans +=a_cnt
        before_s = 'A'
    else:
        a_cnt = 0
        before_s = s[i] s[i] == 'A' s[i] s i 'A' a_cnt += 1 a_cnt 1 before_s = s[i] before_s s[i] s i elif (s[i]=='D'):
        ans +=a_cnt
        before_s = 'A'
     s[i]=='D' s[i] s i 'D' ans +=a_cnt ans a_cnt before_s = 'A' before_s 'A' a_cnt = 0 a_cnt 0 before_s = s[i] before_s s[i] s i print(ans) print ans a_cnt = 0 0 a_cnt before_s = s[i] s[i] before_s before_s = 'A' 'A' before_s ans = 0 0 ans a_cnt = 0 0 a_cnt before_s = s[i] s[i] before_s s = input() input() s s = s.replace('BC','D') s.replace('BC','D') s a_cnt += 1 1 a_cnt before_s = 'A' 'A' before_s ans +=a_cnt a_cnt ans
s = input()
s = s.replace('BC','D')
a_cnt = 0
before_s = 'A'
ans = 0
for i in range(len(s)):

    if s[i] == 'A':
        a_cnt += 1
        before_s = s[i]
    elif (s[i]=='D'):
        ans +=a_cnt
        before_s = 'A'
    else:
        a_cnt = 0
        before_s = s[i]

print(ans)