S = list(input())
N = len(S)

if S[0] == 'A':
    ac = 1
else:
    ac = 0

ans = 0
for i in range(1,N):
    if S[i] == 'A':
        if S[i-1] != 'A':
            ac = 1
        else:
            ac += 1
    elif S[i] == 'B':
        if S[i-1] != 'A':
            ac = 0
    else:
        if S[i-1] == 'B':
            ans += ac
            S[i] = 'A'
        else:
            ac = 0

print(ans)
 S = list(input()) S list(input()) list input() input N = len(S) N len(S) len S if S[0] == 'A':
    ac = 1
else:
    ac = 0 S[0] == 'A' S[0] S 0 'A' ac = 1 ac 1 ac = 0 ac 0 ans = 0 ans 0 for i in range(1,N):
    if S[i] == 'A':
        if S[i-1] != 'A':
            ac = 1
        else:
            ac += 1
    elif S[i] == 'B':
        if S[i-1] != 'A':
            ac = 0
    else:
        if S[i-1] == 'B':
            ans += ac
            S[i] = 'A'
        else:
            ac = 0 i range(1,N) range 1 N if S[i] == 'A':
        if S[i-1] != 'A':
            ac = 1
        else:
            ac += 1
    elif S[i] == 'B':
        if S[i-1] != 'A':
            ac = 0
    else:
        if S[i-1] == 'B':
            ans += ac
            S[i] = 'A'
        else:
            ac = 0 S[i] == 'A' S[i] S i 'A' if S[i-1] != 'A':
            ac = 1
        else:
            ac += 1
     S[i-1] != 'A' S[i-1] S i-1 i 1 'A' ac = 1 ac 1 ac += 1 ac 1 elif S[i] == 'B':
        if S[i-1] != 'A':
            ac = 0
     S[i] == 'B' S[i] S i 'B' if S[i-1] != 'A':
            ac = 0
     S[i-1] != 'A' S[i-1] S i-1 i 1 'A' ac = 0 ac 0 if S[i-1] == 'B':
            ans += ac
            S[i] = 'A'
        else:
            ac = 0 S[i-1] == 'B' S[i-1] S i-1 i 1 'B' ans += ac ans ac S[i] = 'A' S[i] S i 'A' ac = 0 ac 0 print(ans) print ans ac = 1 1 ac ans = 0 0 ans ans += ac ac ans N = len(S) len(S) N S = list(input()) list(input()) S ac = 0 0 ac ac = 1 1 ac ac = 0 0 ac ac += 1 1 ac ac = 0 0 ac
S = list(input())
N = len(S)

if S[0] == 'A':
    ac = 1
else:
    ac = 0

ans = 0
for i in range(1,N):
    if S[i] == 'A':
        if S[i-1] != 'A':
            ac = 1
        else:
            ac += 1
    elif S[i] == 'B':
        if S[i-1] != 'A':
            ac = 0
    else:
        if S[i-1] == 'B':
            ans += ac
            S[i] = 'A'
        else:
            ac = 0

print(ans)

