Competitions

# ABA

The string of letters is given. How many subsequences "ABA" does it contain? The letters "ABA" don't have to be consecutive. But the order of letters should be the same.

#### Input

One line that contains only capital Latin letters. The length of the string is no more than 106.

#### Output

Print the number of subsequences "ABA" in the string.

Time limit 1 second
Memory limit 128 MiB
Input example #1
YARBRBAQ

Output example #1
2
Input example #2
ABAYBATATBBAZA

Output example #2
29