ABA#9594

ABA

1 secondo
128 megabyte
Molto facile

The string of letters is given. How many times the subsequence "ABA" occurs in the given string? The letters "ABA" may not be adjacent, but their order must be preserved.

Input

One line containing only uppercase Latin letters. The length of the string does not exceed 10^6.

Output

Print the number of occurrences of the subsequence "ABA" in the string.

Esempi

Esempio 1

Loading
Loading

Esempio 2

Loading
Loading