eolymp
bolt
Try our new interface for solving problems

ABA

Time limit 1 second
Memory limit 128 MiB

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 data

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

Output data

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

Examples

Input example #1
YARBRBAQ
Output example #1
2
Input example #2
ABAYBATATBBAZA
Output example #2
29